Package: amqp-client-cli
amqp-client-cliA simple CLI tool for sending amqp messages to exchanges.What is the purpose ofamqp-client-cli?The purpose of this command line tool is to make sending messages to exchanges as simple as possible. Uses include:Incronscripts that periodically send simple messages to anampqserver for workers to pick up.Unit testing during implementation of anamqpsystem into a workflow.Simple one-off queue messages where anything more than a simple command line tool is a hassle to use.What doesamqp-client-clinotdo?This tool isnotintended for configuration. It assumes your entire infrastructure is already in place. It canonlysend to existing exchanges and vhosts and provide a routing key.It is up to you to configure your infrastructure elsewhere before using this tool (i.e. through your queue workers, through something likerabbitmqadmin, through a web management console. etc).How do I get it?Install via pip:pip install amqp_client_cliHow do I use it?amqp-client-cliis run via theamqpclicommand. Run thehelpsubcommand to see the list of options:$ amqpcli --help
usage: amqpcli [-h] {send,config} ...

A command line interface for interacting with amqp exchanges

positional arguments:
  {send,config}
    send         Send a message to an exchange.
    config       Configure the amqpcli client.

optional arguments:
  -h, --help     show this help message and exitLet's send a message!Sending messages can be done using theamqpcli sendcommand.$amqpcli send --help
usage: amqpcli send [-h] [-n] (-m MESSAGE | -f FILE_PATH) [-p] [-s] [-u USER] [-v VHOST]
                    host port exchange routing_key

positional arguments:
  host                  Address of the amqp server.
  port                  Port of the amqp server.
  exchange              Name of the exchange being sent to.
  routing_key           The routing key for the message.

optional arguments:
  -h, --help            show this help message and exit
  -n, --nocolor         Do not colorize output.
  -m MESSAGE, --message MESSAGE
                        String to use as the message body.
  -f FILE_PATH, --file-path FILE_PATH
                        Path of a file to use as the message body.
  -p, --persistent      Make the message persistent if routed to a durable queue.
  -s, --ssl             Use ssl/tls as the connection protocol.
  -u USER, --user USER  User to connect to the queue as.
  -v VHOST, --vhost VHOST
                        The vhost to connect to.Let's assume we have aRabbitMQserver listening atlocalhost:5671with an exchange we would like to send a message to namedexchange_aon a vhostmy_vhostwith a routing key ofsimple_message. We are going to send via theguestuser.Let's define our message on the command line!$ amqpcli send localhost 5671 exchange_a simple_message -m "Hello there" -v my_vhost -s
User: guest
Password:
Connecting to queue @ localhost:5671... SUCCESS!
Message successfully published to exchange [exchange_a]!Let's define our message as a file!The message body can also be a file. It will be interpreted as binary.Warning:Althoughanybinary content can be sent, it isnotrecommended to insert large payloads into the queue for performance reasons.$echo"I'm a message in a file">my_message.txt$ amqpcli send localhost 5671 exchange_a simple_message -f my_message.txt -v my_vhost -s
User: guest
Password:
Connecting to queue @ localhost:5671... SUCCESS!
Message successfully published to exchange [exchange_a]!How can I specify credentials/configurations for a script?You can optionally add user credentials to a config file for use with the tool (~/.amqpclirc). There is no limit to the number of users that can be added.Configuration options can be seen from the command line.$ amqpcli config --help
usage: amqpcli config [-h] {add_user,delete_user,list_users} ...

positional arguments:
  {add_user,delete_user,list_users}
    add_user            Add a new queue user to config or edit an existing one.
    delete_user         Delete an existing user from the config.
    list_users          List existing users in config.

optional arguments:
  -h, --help            show this help message and exitWithadd_user, you will be prompted for a username, password, and vhost (default is/).A user can also be specified in the environment variables by definingAMQP_USER,AMQP_PASSWORD, andAMQP_VHOST.$ amqpcli config add_user
User: guest
Password:
vhost? [/]: my_vhost
$ amqpcli send localhost 5671 exchange_a simple_message -m "Hello there" -u guest
Connecting to queue @ localhost:5671... SUCCESS!
Message successfully published to exchange [exchange_a]!