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

sharonbn Sharon.Ben-Asher at AVG.com
Sun Sep 2 14:06:20 BST 2012


I created a simple client in Java, which consumes messages from a queue in a
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

is this expected behavior? can this be changed?

here is the stack trace, the client code is below.

Test at localhost:62105	
	Thread [main] (Suspended (breakpoint at line 19 in Test))	
		Test.main(String...) line: 19	
	Thread [AMQP Connection] (Running)	
	Thread [pool-1-thread-1] (Running)	
	Thread [pool-1-thread-2] (Running)	
	Thread [pool-1-thread-3] (Running)	
	Thread [pool-1-thread-4] (Running)	
	Thread [pool-1-thread-5] (Running)	


import com.rabbitmq.client.*;

public class Test
	static Connection connection;
	static Channel channel;
	static QueueingConsumer consumer;

	public static void main (String... args) throws Exception
		ConnectionFactory factory = new ConnectionFactory();
		connection = factory.newConnection();
		channel = connection.createChannel();
		consumer = new QueueingConsumer(channel);
		channel.basicConsume("q0", true, consumer);

		for (int i = 0 ; i < 10 ; i++) {
			QueueingConsumer.Delivery d = consumer.nextDelivery();
			System.out.println(" got: " + new String(d.getBody()));
			try { Thread.sleep(1000); } catch (InterruptedException e) {}

View this message in context: http://rabbitmq.1065348.n5.nabble.com/Java-client-lib-up-to-5-threads-created-in-client-when-server-publishes-new-message-tp21751.html
Sent from the RabbitMQ mailing list archive at Nabble.com.

More information about the rabbitmq-discuss mailing list