[rabbitmq-discuss] RabbitMQ - unable to consume unfinished messages?

Rajasekhar P sekhar434145 at gmail.com
Wed Oct 23 08:21:28 BST 2013


We are testing unfinished messages scenario in RabbiMQ, where am running
two consumers in separate command prompts, here Producer sends messages
from "Message1 to Message10" and two consumers will consume messages in
round-robin passion like "Message1" goes to "Consumer1" and "Message2" will
go to "Consumer2", etc.  To test unfinished messages what I have done is
when one of the consumer [ex.Consumer2] received "Message2" then am not
sending acknowledgement back to the server.  In this case as per the
documentation other consumer[Consumer1] has to consume message[Message2]
from the server right? But, Its not happening, Consumer1 consuming
remaining messages but not "Message2", why?


Please find the sample code at consumer end below-

while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
String message = new String(delivery.getBody());
 System.out.println(" [x] Received '" + message + "'");
doWork(message);
System.out.println(" [x] Done");

 if(!message.equals("Message2")){
channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
}
}

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131023/89e25618/attachment.htm>


More information about the rabbitmq-discuss mailing list