Message Bus. Subscribers numbers ?

Nov 22, 2011 at 3:29 PM

Hello !

Great framework ! Good work !

I would like to known if with your message bus system we can get informations about the number of subscribers to some message.  I would like to get this information before doing a "SendMessage".

Thanks for any response.

Nov 27, 2011 at 11:10 PM

The subscriber list is maintained internally within the MessageBus.  It's a bit tricky because it maintains a list of weak references to avoid memory leaks.  I would not recommend making it public.  How would you want to use that information?  Perhaps you could add an event to the MessageBus that fires every time the Register and Unregister methods are called?  Then store that information externally to the MessageBus.



Nov 28, 2011 at 8:27 AM

Ok, thank you for help!

I need it because I have a ViewModel "asking" other viewmodels throught message bus. The sender is waiting for subscriber's responses to make some actions. But, in case of there's no subscribers, I need to do some other actions. Maybe your "event" system could be a solution.



Nov 28, 2011 at 12:28 PM

Are you using NotificationEventArgs<TOutgoing, TIncoming> in order for the receiver to call back the sender?  You could try sending a message, then in the Completed handler set a flag if the message was replied to by the receiver.  If the message was not "answered" then you know there are no subscribers listening for it.

Dec 1, 2011 at 8:52 AM

Hello !

Yes I'am using NotificationEventArgs<TOutgoing, TIncoming>. I have done what you say (flag in the message) and it's works. Thank you for your support.