Re: [masstransit-discuss] Multiple bus instances on a windows service

834 views
Skip to first unread message

Travis Smith

unread,
Dec 19, 2012, 6:52:30 AM12/19/12
to masstrans...@googlegroups.com
There's nothing that would "break" having multiple bus instances. I've had to do it when cross talking between busses. Just make sure each instance has it's own queue. Additionally, the sbc.Subscribe line is likely not exactly how it will, but I think generally you're on track.

How many consumers do you run? At my place, we have about 20 services, and just split this up into services instead of all handled in one service. It allows some flexibility and we can restart one without waiting for a long running service. If you restart and there's a long running consumer, it will try and wait out the consumption. Now more services is a deployment problem, but easily solved by automation. 

-Travis



On Wed, Dec 19, 2012 at 12:25 AM, Dhanushka Nuwan <dhanush...@gmail.com> wrote:
I have few web applications publishing messages and a windows service that consumes the messages.
Web applications publish different types of messages for the service to consume. There are about 15 message types and some messages have multiple consumers.
Some consumers take about 10 minutes to process a message. When i use a single bus instance to handle all the message types with 
different consumers, Message at the top of the queue starts consuming. But the next messages does not get consumed untill the first finishes.
I can increase the concurrent consumer limit. But still consumers wait for the above consumers to finish.

So what i am thinking is to have a single publisher bus instance per application, and multiple bus instances on windows service to consume 
different types of messages with their own end point. Below is a sample code of the service

IList<IServiceBus> serviceBusses = new List<IServiceBus>();

// subscribers are read from configuration section.
foreach (SubscriberElement subscriber in subscribers)
{
serviceBusses.Add(MassTransit.ServiceBusFactory.New(sbc =>
{
sbc.UseRabbitMq();
sbc.ReceiveFrom(subscriber.endpoint);
sbc.Subscribe(s => s.Consumer<subscriber.consumertype>());
sbc.SetConcurrentConsumerLimit(subscriber.concurrentlimit);
}));
}

In most of the documents it is recomended to use a single bus instance per application. 
Is it ok to have multiple bus instances open on a windows service?

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/sMYjrAKcAmkJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dru Sellers

unread,
Dec 19, 2012, 8:04:18 AM12/19/12
to masstrans...@googlegroups.com
+1 for more services each with one bus over 1 services with multiple busses.

Chris Patterson

unread,
Dec 19, 2012, 8:13:42 AM12/19/12
to masstrans...@googlegroups.com
I've done both, single service with 2-3 bus instances, and a single bus per service. It just depends upon context/scaling expectations of the services. I don't always code them so they could be split up easily into multiple windows services, but when I do, it's easy to put them into their own Topshelf instance down the road. Sometimes operations isn't ready for you to dump ten new services on them for a few feature.

Keeping the dependencies minimized and avoiding accidental coupling is always good advice in this scenario.

Wiebe Tijsma

unread,
Dec 19, 2012, 8:18:38 AM12/19/12
to masstrans...@googlegroups.com
We've been running with around 60 bus instances (=queues, on top of RabbitMQ) shared over 4 services in production for a while and that works just fine..

Wiebe.

Wiebe Tijsma
Net Industry
Kloveniersburgwal 17F
1011JT Amsterdam
+31624326869
wi...@netindustry.nl
http://www.netindustry.nl

Dhanushka Nuwan

unread,
Dec 19, 2012, 10:48:01 PM12/19/12
to masstrans...@googlegroups.com
We have about 5 consumers now and adding more in the recent future. Should split some of the consumers into services. Thanks Travis.

Dhanushka
Reply all
Reply to author
Forward
0 new messages