Command-line tool (Windows/macOS/Linux) to interact with the Amazon MQ message broker. Interaction with a regular ActiveMQ broker (JMX not required) is also supported. The ActiveMQ Web Console must be available for amazonmq-cli to function properly.
Download amazonmq-cli in the release section of this repository.
Unzip the amazonmq-cli-x.x.x.zip file and configure the broker you want to connect to in amazonmq-cli-x.x.x/conf/amazonmq-cli.config
:
broker {
my-aws-broker {
web-console = "https://your-amazon-mq-broker-host:8162/admin/"
amqurl = "ssl://your-amazon-mq-broker-host:61617"
username = "admin"
password = ""
prompt-color = "light-blue" // Possible values: "gray", "red", "light-red", "light-green", "green", "light-yellow", "yellow", "light-blue", "blue", "light-purple", "purple", "light-cyan", "cyan", "light-white", "white"
}
// add additional brokers here
test {
web-console = "https://your-amazon-mq-test-broker-host:8162/admin/"
amqurl = "ssl://your-amazon-mq-test-broker-host:61617"
username = "admin"
password = "secret"
prompt-color = "light-blue" // Possible values: "gray", "red", "light-red", "light-green", "green", "light-yellow", "yellow", "light-blue", "blue", "light-purple", "purple", "light-cyan", "cyan", "light-white", "white"
}
}
To enter the amazonmq-cli shell run amazonmq-cli-x.x.x/bin/amazonmq-cli
or amazonmq-cli-x.x.x/bin/amazonmq-cli.bat
if you are using Windows.
amazonmq-cli provides tab completion to speed up typing commands, to see which commands are available and what parameters are supported.
In addition to executing commands in the shell, amazonmq-cli also supports executing a file containing commands:
amazonmq-cli --cmdfile my_commands.txt
To connect to a broker that is configured in amazonmq-cli-x.x.x/conf/amazonmq-cli.config
: connect --broker dev
Below is a list of commands that amazonmq-cli supports.
Adds a queue.
- name
Example:add-queue --name foo
Adds a topic.
- name
Example:add-topic --name foo
Browse messages. The browse operation may not return all messages due to limitations of broker configuration and system resources.
- queue
- selector (browse messages that match the (JMS) selector)
- regex (browse messages whose body match the regex)
Example 1:browse-messages --queue foo
Example 2:browse-messages --queue foo --selector "JMSCorrelationID = '12345'"
Example 3:browse-messages --queue foo --regex bar
Connects amazonmq-cli to a broker.
- broker (broker must be defined in
amazonmq-cli-x.x.x/conf/amazonmq-cli.config
)
Example:connect --broker my-aws-broker
Copies messages from a queue to another queue.
- from
- to
- selector (copy messages that match the (JMS) selector)
Example:copy-messages --from foo --to bar
For this command amazonmq-cli consumes all messages from the --from queue and sends the messages back to the --from and --to queues. In flight messages are not in scope of this command.
Disconnects amazonmq-cli from the broker.
Example:disconnect
Exports messages to file.
- file
- queue
- selector (export messages that match the (JMS) selector)
Example:export-messages --queue foo
For this command amazonmq-cli consumes all messages from the --from queue and sends the messages back to the --from queue. In flight messages are not in scope of this command.
Displays information (e.g. version, uptime, total number of queues/topics/messages) about the broker
Example:info
Browses messages. This command may not return all messages due to limitations of broker configuration and system resources. Use export-messages to retrieve all messages of a queue.
- queue
- selector (lists messages that match the (JMS) selector)
- regex (lists messages whose body match the regex)
Example 1:browse-messages --queue foo
Example 2:browse-messages --queue foo --selector "JMSCorrelationID = '12345'"
Example 3:browse-messages --queue foo --regex bar
Lists queues.
- filter (list queues with the specified filter in the name)
- pending (list queues for which the number of pending messages meets the pending filter)
- enqueued (list queues for which the number of enqueued messages meets the enqueued filter)
- dequeued (list queues for which the number of dequeued messages meets the dequeued filter)
- consumers (list queues for which the number of consumers meets the consumers filter)
Example 1:queues --filter foo
Example 2:queues --pending >0 --consumers =0
Lists topics.
- filter (list topics with the specified filter in the name)
- enqueued (remove topics for which the number of enqueued messages meets the enqueued filter)
- dequeued (remove topics for which the number of dequeued messages meets the dequeued filter)
Example 1:topics --filter foo
Example 2:topics --enqueued >0
Moves messages from a queue to another queue.
- from
- to
- selector (move messages that match the (JMS) selector)
For this command amazonmq-cli consumes all messages from the --from queue and sends the messages to the --to queue. In flight messages are not in scope of this command.
Purges all queues.
- force (no prompt for confirmation)
- dry-run (use this to test what is going to be purged, no queues are actually purged)
- filter (queues with the specified filter in the name)
- pending (purge queues for which the number of pending messages meets the pending filter)
- enqueued (purge queues for which the number of enqueued messages meets the enqueued filter)
- dequeued (purge queues for which the number of dequeued messages meets the dequeued filter)
- consumers (purge queues for which the number of consumers meets the consumers filter)
Example 1:purge-all-queues
Example 2:purge-all-queues --filter foo --consumers =0 --dry-run
Purges a queues.
- name
- force (no prompt for confirmation)
Example:purge-queue --name foo
Displays the release notes.
Example:release-notes
Removes all queues.
- force (no prompt for confirmation)
- dry-run (use this to test what is going to be removed, no queues are actually removed)
- filter (queues with the specified filter in the name)
- pending (remove queues for which the number of pending messages meets the pending filter)
- enqueued (remove queues for which the number of enqueued messages meets the enqueued filter)
- dequeued (remove queues for which the number of dequeued messages meets the dequeued filter)
- consumers (remove queues for which the number of consumers meets the consumers filter)
Example 1:remove-all-queues
Example 2:remove-all-queues --filter foo --consumers =0 --dry-run
Removes all topics.
- force (no prompt for confirmation)
- dry-run (use this to test what is going to be removed, no queues are actually removed)
- filter (queues with the specified filter in the name)
- enqueued (remove topics for which the number of enqueued messages meets the enqueued filter)
- dequeued (remove topics for which the number of dequeued messages meets the dequeued filter)
Example 1:remove-all-topics
Example 2:remove-all-topics --filter foo --enqueued =0 --dry-run
Removes a queue.
- name
- force (no prompt for confirmation)
Example:remove-queue --name foo
Removes a topic.
- name
- force (no prompt for confirmation)
Example:remove-topic --name foo
Sends a message or file of messages to a queue or topic.
- body
- queue
- topic
- priority (not applicable if -file is specified)
- correlation-id (not applicable if -file is specified)
- reply-to (not applicable if -file is specified)
- delivery-mode (not applicable if -file is specified)
- time-to-live (not applicable if -file is specified)
- times (number of times the message is sent)
- file
Example file:
<jms-messages>
<jms-message>
<body>Message 1</body>
</jms-message>
<jms-message>
<body>Message 2</body>
</jms-message>
<jms-message>
<header>
<priority>0</priority>
<correlation-id>12345</correlation-id>
<reply-to>myRepliesQueue</reply-to>
<delivery-mode>2</delivery-mode>
<time-to-live>1000</time-to-live>
</header>
<properties>
<property>
<name>my_custom_property</name>
<value>1</value>
</property>
</properties>
<body><![CDATA[<?xml version="1.0"?>
<catalog>
<book id="1">
<author>Basil, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2002-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>
</catalog>]]></body>
</jms-message>
</jms-messages>
Example 1:send-message --body foo --queue bar
Example 2:send-message --file foo.xml --topic bar