Roger-Q is a tool to handle RabbitMQ queues, and it includes commands to dump, dedupe and publish messages.
Run this to download the latest release from Github, move it into your bin folder, and make it executable:
curl -L https://github.com/liip/roger-q/releases/latest/download/roger-q.phar > /usr/local/bin/roger-q
chmod a+x /usr/local/bin/roger-qTo get the list of all commands, run roger-q.phar list
To see all options of a command, run roger-q.phar {commmand} --help.
Except for dedupe, the commands require the --host option to know where to find RabbitMQ, and --username,
--password and --vhost. The default is localhost on port 5672 with vhost / and credentials guest/guest.
(Hint: Pull request to support a configuration file for these parameters would be welcome.)
Dumps the messages from the given queue to the standard output. The command uses the RabbitMQ management API, rather
than the regular protocol, to read and write messages, which is much faster for queues with many messages. This means
that you need to install the Management Plugin in your RabbitMQ. If you do
not use the default port 15672, you need to specify the --port parameter.
The messages are dumped as JSON as in the following example (the example has been pretty-formatted):
[
{
"payload_bytes": 129,
"redelivered": false,
"exchange": "my-exchange-name",
"routing_key": "routing-key",
"message_count": 3891,
"properties": {
// Message headers here
},
"payload": "The message payload",
"payload_encoding": "string"
},
// Next messages here...
]Example usage:
# roger-q.phar dump queue-nameIn the following example the messages from messages.txt file will be de-duplicated by checking the uniqueness of the
given field.
The resulting messages are outputted to the standard output.
# cat messages.txt | roger-q.phar dedupe id-fieldReads messages from the standard input and publishes them to the specified queue. Usually, you would send messages to an exchange rather than a queue directly, but the use-case of this tool is to clean up queues. If you specify an exchange instead of a queue, the messages will be reported as published but not arrive anywhere.
The following example will publish the messages from the messages.txt file into the queue-name queue.
The queue is additionally purged before starting the publishing operation.
# cat messages.txt | roger-q.phar publish queue-name --purgeBox is used to build a precompiled PHAR file of the application.
Run make dist to:
- download the box library in
tools/(if not present) - create the PHAR executable in
dist/roger-q.phar
To run the PHP coding-styles checks (php-cs-fixer and phpstan) run the make phpcs command to:
- download the
php-cs-fixertool intools/(if not present) - download the
phpstantool intools/(if not present) - Run
php-cs-fixeron the source code - Run
phpstanon the source code