How to view queue in rabbitmq without deleting messages

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;
            }
        }

`

+4
source share
2 answers

You cannot do what you want as you want. Selective Consumer is an anti-pattern in RabbitMQ.

RabbitMQ, , .

: http://derickbailey.com/2015/07/22/airport-baggage-claims-selective-consumers-and-rabbitmq-anti-patterns/

+2

, .

.

, .

0

Source: https://habr.com/ru/post/1628182/


All Articles