[rabbitmq-discuss] Java client lib: up to 5 threads created in client when server publishes new message

Simon MacMullen simon at rabbitmq.com
Mon Sep 3 17:54:51 BST 2012

On 03/09/12 17:40, Simon MacMullen wrote:
> On 02/09/12 14:06, sharonbn wrote:
>> I created a simple client in Java, which consumes messages from a
>> queue in a
>> loop.
>> what I see in the debugger, is that whenever I publish a new message into
>> queue "q0"
>> a new thread is opened in the client. until 5 threads are open and
>> running.
>> (this is besides the single thread named "AMQP Connection")
>> the threads begin when the messages are published, not when they are
>> consumed...
>> is this expected behavior?

Ah, I missed "the threads begin when the messages are published, not 
when they are consumed."

The threads are started up when the message is consumed by the client 
(which is likely to be very soon after you published!) But this could be 
some time before you invoke QueueingConsumer.nextDelivery() - since 
QueueingConsumer will of course itself queue these messages.

> Yes. This is the thread pool for consumer callbacks to get executed in.
>> can this be changed?
> Yes, invoke ConnectionFactory.newConnection(ExecutorService, Address[])
> with a different ExecutorService.

...or ConnectionFactory.newConnection(ExecutorService). See:


Cheers, Simon

Simon MacMullen
RabbitMQ, VMware

More information about the rabbitmq-discuss mailing list