2
votes

I'm getting started with NServiceBus and have a question about the Pubsub sample.

My intention was to have multiple instances of Publisher1 running and receiving the message sent from the publisher. I also hacked the Publisher to only send messages of the eventMessage type.

But if I start the publisher and three instances of Subscriber1, only one of them gets the message at a time.

why is that? Is it a config setting or something else?

This is what I've tried which returns an exception "Exception when starting endpoint, error has been logged. Reason: Cannot configure property before the component has been configured. Please call 'Configure' first.":

using NServiceBus;

namespace Subscriber1
{
    public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
    {
    }

    public class OverrideInputQueue : IWantCustomInitialization
    {
        public void Init()
        {
            Configure
                .Instance
                .Configurer
                .ConfigureProperty<NServiceBus.Config.MsmqTransportConfig>(t => t.InputQueue, "testQueue");
        }
    }
}

/J

2

2 Answers

1
votes

NServiceBus assumes that you have one input queue per process. Make sure that each of your subscribers are configured with a unique input queue. If not all three will be polling the same queue producing the behavior you're describing.

To do this you would probably have to copy paste sub1 to 3 different folders, modfying the app.config and start them up.

Hope this helps!

0
votes

You should use this-

Configure.Instance.Configurer.ConfigureProperty<NServiceBus.Unicast.Transport.Msmq.MsmqTransport>(msmq => msmq.InputQueue, "SomeQueueHere");

Make sure you use MsmqTransport and not MsmqTransportConfig as you mentioned.