Cysharp/MessagePipe

Question: Behaviour for distributed publishers/subscribers

iangralinski-invetech opened this issue · 2 comments

When using IDistributedPublisher<TKey, TMessage> and IDistributedSubscriber<TKey, TMessage>, is the intended behaviour that the subscriber message handler gets invoked only based on the type of TKey, or both TKey and TMessage.

For instance, if I have TKey=int with two different message types TMessage=Message1 and TMessage=Message2, then I publish using the distributed publisher PublishAsync(1, new Message1()), is it expected that a subscriber that is only handling Message2 would receive this message?

When you use the keyed pub/sub asymmetrical api you setup your subscription to listen on that key and type pairing, period. Unlike the non-keyed api the keyed api will not broadcast to a set of subscribers listen on a type; conversely, if you have more than one part of your application listen on a keyed/Type pairing and you have the prerequisite handlers setup the they will receive data on the keyed/typed pairing. If you have a different keyed/type pairing you'll need a specific handler for it.

Thanks TaviTruman for your explanation.