<div dir="ltr">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?<div>
<br></div><div><br></div><div>Please find the sample code at consumer end below- </div><div><br></div><div>while (true) {<br></div><div><div><span class="" style="white-space:pre">                </span>QueueingConsumer.Delivery delivery = consumer.nextDelivery();</div>
<div><span class="" style="white-space:pre">                </span>String message = new String(delivery.getBody());</div><div><span class="" style="white-space:pre">                                </span></div><div><span class="" style="white-space:pre">        </span><span class="" style="white-space:pre">        </span>System.out.println(" [x] Received '" + message + "'");</div>
<div><span class="" style="white-space:pre">                </span>doWork(message);</div><div><span class="" style="white-space:pre">                </span>System.out.println(" [x] Done");</div><div><br></div><div><span class="" style="white-space:pre">        </span><span class="" style="white-space:pre">        </span>if(!message.equals("Message2")){</div>
<div><span class="" style="white-space:pre">                        </span>channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);</div><div><span class="" style="white-space:pre">                </span>}</div></div><div>}</div><div><br></div><div>
Thanks in advance!</div></div>