Multiple Consumers on one bus instance

1,790 views
Skip to first unread message

Tim Thompson

unread,
Mar 3, 2015, 11:10:39 PM3/3/15
to masstrans...@googlegroups.com
G'day all,

We've been using MT in production for about 6 months now, initially for very light scenarios, and we're now becoming increasingly reliant on it.... so far I love it!

One fact I've had in my head as we build services is that a single queue name should only be used by a single instance of the bus, and that it should only host a single consumer.  Also, that you shouldn't publish messages over the same instance you're consuming on.

I was just re-reading the docco on configuring instances out of IoC (http://docs.masstransit-project.com/en/latest/configuration/containers.html)  and realised that this indicates that running multiple consumers is not just possible, but the default behaviour when using LoadFrom().

For my own sanity, can someone please confirm/dispute the correctness of my assumptions?

Keep up the amazing work with the framework, I'm looking forward to V3 :)

Cheers,
Tim

Travis Smith

unread,
Mar 5, 2015, 12:14:07 PM3/5/15
to masstrans...@googlegroups.com
Having multiple consumers, registered at once, on a single bus is acceptable. They are just tied together. The most important this is to have a single bus per queue. When a message is read off the queue, it will be routed to the right consumer, if it's registered, on that bus. 

Also, you can send from the same bus you receive on if you want. There's no harm in that. 

-Travis

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/80e926fb-e528-4f81-9696-5ae39a20bfa3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Thompson

unread,
Mar 5, 2015, 3:23:24 PM3/5/15
to masstrans...@googlegroups.com
Thanks for getting back to me Travis, cheers!

I've obviously got confused somewhere early on (probably from a sentence similar to "You can't run multiple consumers off the one queue" referring to a competing consumer type issue, rather than different message types within an application).

I'm off to simplify some service code :)

Thanks again,
Tim


On Friday, March 6, 2015 at 3:14:07 AM UTC+10, Travis Smith wrote:
Having multiple consumers, registered at once, on a single bus is acceptable. They are just tied together. The most important this is to have a single bus per queue. When a message is read off the queue, it will be routed to the right consumer, if it's registered, on that bus. 

Also, you can send from the same bus you receive on if you want. There's no harm in that. 

-Travis

On Tue, Mar 3, 2015 at 9:08 PM, Tim Thompson <wok...@gmail.com> wrote:
G'day all,

We've been using MT in production for about 6 months now, initially for very light scenarios, and we're now becoming increasingly reliant on it.... so far I love it!

One fact I've had in my head as we build services is that a single queue name should only be used by a single instance of the bus, and that it should only host a single consumer.  Also, that you shouldn't publish messages over the same instance you're consuming on.

I was just re-reading the docco on configuring instances out of IoC (http://docs.masstransit-project.com/en/latest/configuration/containers.html)  and realised that this indicates that running multiple consumers is not just possible, but the default behaviour when using LoadFrom().

For my own sanity, can someone please confirm/dispute the correctness of my assumptions?

Keep up the amazing work with the framework, I'm looking forward to V3 :)

Cheers,
Tim

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Chris Patterson

unread,
Mar 6, 2015, 12:13:49 PM3/6/15
to masstrans...@googlegroups.com
Well, you can do both - you can have multiple message types on a single queue by subscribing consumers with multiple messages types on that bus (which binds to a single queue). This is referred to as multiplexing (different data types on a single channel).

You can also (using say RabbitMQ) have multiple consumers of the same type reading from a single queue, creating a competing consumer scenario. This is typically for either load-balancing, or high availability purposes. In this case, every bus instance with the same queue should have the EXACT same consumers registered with the exact same behavior.

The real key is that each distinct bus/consumer combination has a unique queue.


To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages