skip to content
Alvin Lucillo

Get message then requeue

/ 2 min read

In the example below, the message isn’t visible anymore once you pulled it. But if you supply with --ack-mode=ack_requeue_true argument, the message is pulled and then requeued. This is why when you pull the message again, it has redelivered=true.

  ~ docker exec -it rabbitmq rabbitmqadmin declare queue --name=greetings
  ~ docker exec -it rabbitmq rabbitmqadmin publish message --routing-key=greetings --payload=henlo
Message published and routed successfully
  ~ docker exec -it rabbitmq rabbitmqadmin get messages --queue=greetings
┌───────────────┬─────────────┬──────────┬─────────────┬───────────────┬────────────┬─────────┬──────────────────┐
 payload_bytes redelivered exchange routing_key message_count properties payload payload_encoding
├───────────────┼─────────────┼──────────┼─────────────┼───────────────┼────────────┼─────────┼──────────────────┤
 5 false greetings 0 henlo string
└───────────────┴─────────────┴──────────┴─────────────┴───────────────┴────────────┴─────────┴──────────────────┘
  ~ docker exec -it rabbitmq rabbitmqadmin get messages --queue=greetings
┌───────────────┬─────────────┬──────────┬─────────────┬───────────────┬────────────┬─────────┬──────────────────┐
 payload_bytes redelivered exchange routing_key message_count properties payload payload_encoding
└───────────────┴─────────────┴──────────┴─────────────┴───────────────┴────────────┴─────────┴──────────────────┘
  ~ docker exec -it rabbitmq rabbitmqadmin publish message --routing-key=greetings --payload=henlo
Message published and routed successfully
  ~ docker exec -it rabbitmq rabbitmqadmin get messages --queue=greetings --ack-mode=ack_requeue_true
┌───────────────┬─────────────┬──────────┬─────────────┬───────────────┬────────────┬─────────┬──────────────────┐
 payload_bytes redelivered exchange routing_key message_count properties payload payload_encoding
├───────────────┼─────────────┼──────────┼─────────────┼───────────────┼────────────┼─────────┼──────────────────┤
 5 false greetings 0 henlo string
└───────────────┴─────────────┴──────────┴─────────────┴───────────────┴────────────┴─────────┴──────────────────┘
  ~ docker exec -it rabbitmq rabbitmqadmin get messages --queue=greetings
┌───────────────┬─────────────┬──────────┬─────────────┬───────────────┬────────────┬─────────┬──────────────────┐
 payload_bytes redelivered exchange routing_key message_count properties payload payload_encoding
├───────────────┼─────────────┼──────────┼─────────────┼───────────────┼────────────┼─────────┼──────────────────┤
 5 true greetings 0 henlo string
└───────────────┴─────────────┴──────────┴─────────────┴───────────────┴────────────┴─────────┴──────────────────┘
  ~ docker exec -it rabbitmq rabbitmqadmin get messages --queue=greetings
┌───────────────┬─────────────┬──────────┬─────────────┬───────────────┬────────────┬─────────┬──────────────────┐
 payload_bytes redelivered exchange routing_key message_count properties payload payload_encoding
└───────────────┴─────────────┴──────────┴─────────────┴───────────────┴────────────┴─────────┴──────────────────┘