I am trying to get a message with a specific correlation identifier as described in the rabbitmq docs. However, I see that irrelevant messages are being tricked. I do not want this to happen. How can I say that rabbitmq will not be canceled after I receive the message and find out that this is not the one I was looking for. Please help me.
`
.
.
replyQueueName = channel.queueDeclare().getQueue();
consumer = new QueueingConsumer(channel);
channel.basicConsume(replyQueueName, false, consumer);
while (true) {
QueueingConsumer.Delivery delivery = consumer.nextDelivery();
System.out.println(delivery.getProperties().getCorrelationId());
if (delivery.getProperties().getCorrelationId().equals(corrId)) {
response = new String(delivery.getBody());
break;
}
}
`
source
share