I am learning rabbitMq and and now I want to know how to wath queue content.
First of all I want to day that I googled this question and know about command
python rabbitmqadmin list queues
I have written 2 separated applications.
sender:
@Autowired
private AmqpTemplate template;
...
for (int i = 0; i < 100; i++) {
template.convertAndSend("queue1", "message_" + i);
}
receiver:
@RabbitListener(queues = "queue1")
public void listenQueue1(String message, @Header(AmqpHeaders.DELIVERY_TAG) long tag) {
logger.info("Got message:[" + message + "]");
}
If I run these applications together - I see messages on receiver side.
To see messages in the queue I decided to stop receiver
and run sender
python rabbitmqadmin list queues
and see following result:
+-----------------+----------+
| name | messages |
+-----------------+----------+
| query-example-6 | |
| queue1 | |
| queue2 | |
| queue3 | |
| queue4 | |
| queue5 | |
| queue6 | |
| queue7 | |
| queue8 | |
| queue9 | |
+-----------------+----------+
3.Then I run receiver and see logs that receiver accepted messages
Can you clarify reason why I can't see messages in console?
How to see queue messages content.
I am not familiar with rabbitmq.
maybe the message is "unacknowledged"?
eg I found my queue has a message:
$ rabbitmqadmin list queues name node messages
+----------------------------+----------------+----------+
| name | node | messages |
+----------------------------+----------------+----------+
| my_queue_name | rabbit@xx-2 | 1 |
but when I run "get" command to show its content, rabbitmq tells me "there's no item"
so, I query it with this command:
$ rabbitmqadmin list queues name node messages messages_ready messages_unacknowledged
+----------------------------+----------------+----------+----------------+-------------------------+
| name | node | messages | messages_ready | messages_unacknowledged |
+----------------------------+----------------+----------+----------------+-------------------------+
| my_queue_name | rabbit@xxxxx-2 | 1 | 0 | 1 |
+----------------------------+----------------+----------+----------------+-------------------------+
I don't know why. just restart the rabbitmq server and everything seems goes fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.