Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

RabbitMQ MassTransit batching competing consumers

I’ve set up a batch consumer of an event ExampleEvent and set it to have ConcurrencyLimit = 16, MessageLimit = 100, TimeLimit = 5 sec and grouping by ExampleEvent.GroupingKey field.

This works fine and shows up on Rabbit as a consumer with PrefetchCount = 1600. The thing is that I have a multi pod environment and have more than one consumer like that connected to the same queue. I read that Rabbit distributes messages using a round robin algorithm, however I also read that it will try to saturate one consumer until the PrefetchCount limit of unacked messages is reached. This seems to not be the case (or maybe I’m missing something?).

Now the main problem is that some messages that could’ve been batched with other messages on Consumer 1 are being sent to Consumer 2 (replica). According to logs, they were taken within less than a second of eachother and the message limit was far from being reached.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is it possible to somehow force them to be batched on Consumer 1?

>Solution :

When running multiple instances/pods of the same service, messages on the queue will be load balanced across all instances/pods. There is no way to control the direction of those messages in RabbitMQ so that they only go to a specific instance.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading