views:

38

answers:

1

Hi
I am using NServiceBus 1.9 RTM in my project.
I am using Publisher - Distributor - Subscriber model.
In subscriber I subscribed using the follwoing code

 var bus = NServiceBus.Configure.With()
                .SpringBuilder()                    
                    .XmlSerializer()
                .MsmqTransport()
                    .IsTransactional(false)
                    .PurgeOnStartup(false)
                .UnicastBus()
                    .ImpersonateSender(false)
                    .DoNotAutoSubscribe()
                    .LoadMessageHandlers()
                .CreateBus()
                .Start();
                bus.Subscribe<ITestMessage>();
                _isSubscribed = true;
                log.Info(" ITestMessage Subscribed successfully..");
                _serviceBus = bus;

when i want to unsbuscribe I am doing like

_serviceBus.Unsubscribe<ITestMessage>();

But it's not unsubscribing nor throwing any error. After unsbuscribing also EventHandler still receiving messages from the distributor.

Is there anything that I am missing...? Anyone can help me.

Thanks
nRk

+1  A: 

You need to understand that unsubscribing is not something you do against the distributor but rather against the publisher. Now, it could be that you haven't configured the right endpoint for the publisher of your ITestMessage in your MessageEndpointMappings, and that's why the unsubscribe isn't working. It's likely that the subscribe isn't working either, but that's hidden by the fact that you have configured your distributor correctly, and someone else has told the publisher to subscribe the distributor for the ITestMessage.

Hope that helps.

Udi Dahan
Thanks Udi, I got what you are pointing. But how can I stop Distributor sending messages to my Subscriber? Or Can I stop receiving Messages from Distributor from some time duration? Subscriber is running as windows service. - nRk
nRk