The Competing Consumers pattern
Multiple consumers from the same channel can process messages in parallel thanks to the Competing Consumers pattern. When multiple consumers of the same pool instance need to process several small tasks in parallel and asynchronously, this pattern comes in handy.
In a normal scenario, the traffic coming to the message broker from the publisher is low, and the consumer can process messages at the rate at which they come from the publisher, as shown in Figure 7.7.
Figure 7.7 - Competing Consumers pattern for low traffic
There might be a scenario where the ingress traffic increases, such as when publishers start sending more messages to the queue or the number of publishers increases. In this case, the rate at which messages are published to the queue is faster than that at which they are consumed.
If this happens, we can increase the number of consumers listening to a message stream and allow more than one consumer per...