Is it possible to have several consumers listening on a single MSMQ instance and use the Selective Consumer interface for having each one deal with a distinct subset of the messages? I can't seem to get this scenario to work correctly using pub/sub - a single consumer on the queue works fine, but when using >1 consumers (several instances of the same executable) no messages appear anywhere. As I understand it, this is not the case of 'competing consumers', since only a single consumer will process a single message.
Any help or pointers are appreciated.
If you are using MassTransit to dispatch messages from an MSMQ queue, it is recommended that the queue is local to the box.
That being said, if you have multiple processes that are reading from the same queue for the purposes of distributing the message load, you can use the selective receive to only consume messages in each instance that are relevant to that process.
For example, if you have multiple instances of an application that send messages to a service and that service responds with a correlated message, you can subscribe to the correlated message by identifier and only those subscribed messages will be delivered. The messages that are not selected will remain in the queue until processed by any of the processes that are interested.
Because of this pattern, it is highly recommended that an expiration be set on the message so ignored responses do not clog up the queue over time.
This scenario is pretty common when replicating a request/response pattern via messaging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With