[rabbitmq-discuss] rabbitmq java client keeps pulling data?

DeepNightTwo DeepNightTwo at gmail.com
Fri Sep 19 08:02:17 BST 2014


I created consumer like this:

    ConnectionFactory factory = new ConnectionFactory();
	factory.setHost(host);
	factory.setVirtualHost(vhost);
	factory.setUsername(username);
	factory.setPassword(passwd);
	Connection connection = factory.newConnection();
	Channel channel = connection.createChannel();
	channel.basicQos(4096);
	QueueingConsumer consumer = new QueueingConsumer(channel);
	channel.basicConsume(queueName, true, consumer);
	
	while(true){
		consumer.nextDelivery();
	}

and I found that there is a thread keep pulling data from rabbitmq server.
If the data is consumed slower than produced, lots of Delivery instances may
cause OOM. If I use a fix sized blocking queue to create QueueingConsumer,
it will still keep pulling data and cause the queue full exception:

2014-09-19 14:46:16 STDIO [ERROR] DefaultExceptionHandler: Consumer
com.rabbitmq.client.QueueingConsumer at 2316ea4
(amq.ctag-1Ee7d70sWHCKBdbunbBw-w) method handleDelivery for channel
AMQChannel(amqp://sec-read@10.8.91.153:5672infosec,1) threw an exception for
channel AMQChannel(amqp://sec-read@10.8.91.153:5672infosec,1):
2014-09-19 14:46:16 STDIO [ERROR] java.lang.IllegalStateException: Queue
full
2014-09-19 14:46:16 STDIO [ERROR] at
java.util.AbstractQueue.add(AbstractQueue.java:98)
2014-09-19 14:46:16 STDIO [ERROR] at
com.rabbitmq.client.QueueingConsumer.handleDelivery(QueueingConsumer.java:125)
2014-09-19 14:46:16 STDIO [ERROR] at
com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:140)
2014-09-19 14:46:16 STDIO [ERROR] at
com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:85)
2014-09-19 14:46:16 STDIO [ERROR] at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
2014-09-19 14:46:16 STDIO [ERROR] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)



my question is, is there a size setting for consumer to limit the count of
un-consumed delivery? Or I should use the basicGet api?







--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/rabbitmq-java-client-keeps-pulling-data-tp37080.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list