Home > Net >  How does Concurrency Limit work in MassTransit RabbitMQ?
How does Concurrency Limit work in MassTransit RabbitMQ?

Time:12-22

I am reading about Concurrency Limit in MassTransit RabbitMQ, but I am still not understanding how it really works.

Supposing I have 4 consumers and I configure the queues with concurrency limit to 1 config.UseConcurrencyLimit(1);. When a producer dispatch 4 messages at the same time, what will happen? Just one message will be consumed in just one consumer and all other 3 messages will be discarted?

Could someone explain me how does it work?

CodePudding user response:

The concurrency limit setting applies to the concurrency filter in GreenPipes. It sets a limit on a single consume pipe, which is a pipe for a single consumer type.

It basically tells MassTransit how many (competing) consumers of the same type it can instantiate to handle messages of the same type in parallel.

As rightfully mentioned in the question comments, there's no such thing as "discarding messages" in queueing. Even if you set the limit to one and publish 1000 messages, they will be processed, in this case, one by one.

  • Related