Skip to content

CLI Report of Delayed Message Counts #123

@RyanFrantz

Description

@RyanFrantz

I would like to be able to report the total count of delayed messages within an exchange from the command line. Additionally, it would be great if we could display the count of delayed messages based on their intended queue.

I had a conversation with @michaelklishin about support in the CLI for finding the total count of delayed messages within an exchange. He helped me with an eval statement like the following example:

rabbitmqctl eval 'rabbit_delayed_message:messages_delayed(rabbit_misc:r(<<"vhost_name">>, exchange, <<"exchange_name">>)).'

I tested this running RabbitMQ 3.7.13 in a Docker container that I had just started:

$ docker-compose exec salsa-rabbit rabbitmqctl version
3.7.13

$ docker-compose exec salsa-rabbit rabbitmqctl eval 'rabbit_delayed_message:messages_delayed(rabbit_misc:r(<<"/">>, exchange, <<"salsa">>)).'
0

I expected the total count to be 0 since I had just launched the Rabbit instance and had no messages in it.

However, when I send a delayed message (delayed for a few hours) to Rabbit and run the same eval command, it still returns 0. I've confirmed my exchange exists and is of type x-delayed-message:

$ docker-compose exec salsa-rabbit rabbitmqctl list_exchanges
Listing exchanges for vhost / ...
name    type
amq.direct      direct
amq.match       headers
amq.headers     headers
amq.rabbitmq.trace      topic
amq.topic       topic
amq.fanout      fanout
salsa   x-delayed-message  <<<
        direct

NOTE: When I run the command for an exchange that doesn't actually exist, I get 0 as well, rather than an error stating the exchange is invalid:

$ docker-compose exec salsa-rabbit rabbitmqctl eval 'rabbit_delayed_message:messages_delayed(rabbit_misc:r(<<"/">>, exchange, <<"an_exchange_that_does_not_exist">>)).'
0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions