views:

425

answers:

1

Hi. 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

A: 

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!

Andreas
Yes it does. But then I have to set the queue programatically somehow. Right?? I found something like this: Configure.Instance.Configurer.ConfigureProperty<MsmqTransport>(t => t.InputQueue, yourDynamicQueue);.. but couldn't get it to work.Any tips??
Johan Zell
Yes if you can't copy paste the folder and modify the separate app.config's you'd have to set it programmatically.Take a look here:http://tech.groups.yahoo.com/group/nservicebus/message/6378Can you give some more details on what you're trying to achieve with all this? If it's about distributing load you should look at using the distributor:http://nservicebus.com/Distributor.aspx
Andreas
What I want is to have multiple instances of the same client all receiving messages when certain events happen. Maybe when someone creates a customer, all clients gets a news flash about it.
Johan Zell
But since I'm just starting maybe the pubsub sample isn't the right "template" for this scenario.
Johan Zell
You need to programmatically set the input queue in a IWantCustomInitialization class that is different from the IConfigureThisEndpoint class.
Udi Dahan
Like above where I have the endpoint class and a OverrideInputQueue class which implements IWantCustomInitialization. They are separate classes.
Johan Zell
I did succeed in running the sample when I changed the above Init code to: Configure .Instance .Configurer .ConfigureComponent<NServiceBus.Config.MsmqTransportConfig>(NServiceBus.ObjectBuilder.ComponentCallModelEnum.None) .ConfigureProperty(t => t.InputQueue, "testQueue");But it still uses the InputQueue specified in the config file.
Johan Zell
You need to configure the MsmqTransport itself as follows: Configure.Instance.ConfigureComponent<MsmqTransport>(t => t.InputQueue, yourDynamicQueue); rather than MsmqTransportConfig.
Udi Dahan