I have system with one publisher several subscribers. But some messages should be processed only by single subscriber. In my case publisher sends message about changing data in database, all subscribers has access to the same database, but I don't need them all change the same data. How can this be accomplished using rebus?
PS. Forgot to mention. I can't subscribe to the message only with one subscriber, because subscriberss can go online/offline all the time.
Then you should not use
bus.Publish
for that particular message type - there is a mechanism that sends messages to one particular recipient which you should use - you do it byYou do (1) like this:
thus telling Rebus that whoever gets its messages from the queue
the_recipient
is the owner of messages of typeYourMessage
and should be considered the natural recipient for an implicitly routed message of that type.You do (2) like this:
and then Rebus will send the message to the message's natural owner.
I hope that does the trick for you :)