Camel RabbitMQ user: what is the interaction between concurrentConsumers and threadPoolSize?

The Camel RabbitMQ component allows you to set both the concurrentConsumers option and threadPoolSize . Their description and default values ​​are as follows:

concurrentConsumers - the default value is 1 - The number of concurrent consumers consumed by the broker. (for example, similar to the same option for JMS).

threadPoolSize - the default value is 10 - the consumer uses the Executor thread pool with a fixed number of threads. This parameter allows you to set this number of threads.

Can anyone explain how the two will interact, especially in terms of performance?

In particular, we delve a little into nuance:

  • Are they grossly interchangeable? That is, it is approximately so that 2 consumers, 5 threads ~ 5 consumers, 2 threads?
  • Does each concurrent consumer receive as many threads as indicated in threadPoolSize , or are these threads shared among all concurrent consumers?

Thank you very much!

+5
source share
2 answers

I did some tests on my machine, and this is what I got (I did not go through the docs so I could be wrong):

1. I noticed that the number of consumers is the number of “listeners” that you will attach to your queue (they can receive a message, but delegate processing to workflows). The number of threads is the number of workers who will process the message.

Test 1: With 1 thread, 10 consumers, and 10 messages, you will have 10 messages delivered at the same time (but not suspended), with 1 being processed by one worker thread.

Test 2: With 10 threads, 1 consumer and 10 messages, you will also process 1 message at a time, but while the message is being processed, the rest are available in the queue (only 1 is delivered at a time), so if another listener joins, it will be able to process the remaining messages ( not in the first example).

2. I think that the threads are separated, because if this is not so, in Test 1 10 messages will be consumed in parallel (1 thread for each consumer, only 10 threads, not just one), which is not what happened.

Hope this helps!

+2
source

Here:

The RabbitMQ component uses one RabbitMQ Connection consumer for each camel (not RabbitMQ). This means that if you have 5 buyers with camel crumbs, Camel will open 5 connections, each of which has threadpool the size of threadPoolSize , regardless of the concurrentConsumers parameter.

0
source

Source: https://habr.com/ru/post/1242755/


All Articles