Setting concurrency limit on receive endpoint

1,526 views
Skip to first unread message

Scott Vickers

unread,
Jan 7, 2016, 3:13:25 PM1/7/16
to masstransit-discuss
Am I missing something necessary for limiting concurrency?  This does not seem to be working as I would expect:

cfg.ReceiveEndpoint("ml", ec =>

                   {

                       ec.Consumer<Headset.Consumers.Menus.PredictCategory>(context.Resolve<ILifetimeScope>());

                       ec.UseConcurrencyLimit(1);

                   });


In the log I can see it pops 14 messages right away:

2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.649
Starting category prediction
2016-01-07 11:49:05.799
Starting category prediction
2016-01-07 11:49:05.799
Starting category prediction
2016-01-07 11:49:05.799
Starting category prediction
2016-01-07 11:49:05.799
Starting category prediction

andy...@pmas.co.uk

unread,
Jan 8, 2016, 4:00:02 AM1/8/16
to masstransit-discuss
I normally set the prefetch count to limit

cfg.ReceiveEndpoint("ml", ec =>

                 {

                     ec.Consumer<Headset.Consumers.Menus.PredictCategory>(context.Resolve<ILifetimeScope>());

                    ec.UseConcurrencyLimit(1);

                    ec.PrefetchCount = 1;

               });

Scott Vickers

unread,
Jan 9, 2016, 8:52:42 PM1/9/16
to masstransit-discuss
I thought about that but the docs explicitly say the prefetch count should be a multiple of the concurrency limit: http://masstransit.readthedocs.org/en/master/overview/underthehood.html?highlight=concurrency

Also it looks like you can't set the prefetch at the endpoint, only the host.

Chris Patterson

unread,
Jan 9, 2016, 9:28:15 PM1/9/16
to masstrans...@googlegroups.com
I wrote a test to verify and concurrency limit works so I'm not sure what you're seeing. I had the prefetch on RMQ set to 16 and it kept the consumer locked to only one message at a time. 

Also prefetch count can be set on the receive endpoint for RabbitMQ. Make sure you use the (host, queueName, configurator) overload that is RabbitMQ specific. 


__
Chris Patterson




--
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/28e81ed8-6441-4220-98a3-b24893c78028%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Patterson

unread,
Jan 9, 2016, 9:30:31 PM1/9/16
to masstrans...@googlegroups.com
Okay. I see it now. Order matters when building the pipeline. Move the concurrency limit method above the consumer method.

You can use the probe to display the pipeline. 


That should fix you up. 

__
Chris Patterson




--
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.

Scott Vickers

unread,
Jan 10, 2016, 1:04:46 AM1/10/16
to masstransit-discuss
That did it, order is everything.  Thanks again for your help Chris!
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages