开发者

NServiceBus Listener Missing Messages

开发者 https://www.devze.com 2022-12-09 12:42 出处:网络
I am just starting to play with nservice bus and am trying to get publishing working.I have a listener which seems to be missing some messages.It is configured with

I am just starting to play with nservice bus and am trying to get publishing working. I have a listener which seems to be missing some messages. It is configured with

 <MsmqTransportConfig
  InputQueue="InformMessages"
  ErrorQueue="error"
  NumberOfWorkerThreads="5"
  MaxRetries="5"
 />

Interestingly if I set NumberOfWorkerThreads to 1 it consistently misses every other message. For larger values it seems less determinate. I开发者_高级运维n my message handler I have

class MessageHandler : IMessageHandler<ICourseRegister>
{
    public void Handle(ICourseRegister message)
    {
        Console.WriteLine("Message dun got gotted");
        Console.WriteLine("Course name is: " + message.CourseName);
    }

    private IBus bus;
    public IBus Bus
    {
        set { this.bus = value; }
    }
}

and the bus is configured with

        var bus = NServiceBus.Configure.With()
              .SpringBuilder()
              .XmlSerializer()
              .MsmqTransport()
                  .IsTransactional(true)
                  .PurgeOnStartup(false)
              .UnicastBus()
                  .ImpersonateSender(false)
                  .LoadMessageHandlers()
              .CreateBus()
              .Start();

Is there something I need to do and the end of Handler such that it is freed ready to receive the next message or some configuration I need to do so that there is a client side queue to retain messages if the handler is busy. The time between sending messages doesn't seem to matter, it could be 20 seconds and the listener still doesn't get all the messages.


After taking a look at the solution you sent over, I see what the problem is.

You've specified the same input queue for both processes - the publisher and the subscriber. As a result, you have both processes fighting over the messages which (I think) you intend to be going only to the subscriber.

Give each process its own input queue and everything should be right with the world :-)


If you're working similar to the pub/sub sample, what you could be seeing is "polymorphic subscriptions".

In the pub/sub sample, the publisher alternately publishes an interface IEvent and a concrete class EventMessage (which inherits IEvent).

If a subscriber is subscribed to the concrete class, then it won't receive the interface messages. This is true for all kinds of hierarchies, if you subscribe to the specific class, and the publisher publishes a message of the type of its base class, the message won't be dispatched.

The polymorphic subscriptions works the other way around. If you subscribe to the base, any subclass that the publisher publishes will arrive.

This has nothing to do with threading.

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消