Skip to content

Latest commit

 

History

History
356 lines (263 loc) · 9.95 KB

README.md

File metadata and controls

356 lines (263 loc) · 9.95 KB

activemq-cli

Command-line tool (Windows/macOS/Linux) to interact with a JMX enabled Apache ActiveMQ message broker.

Your broker is not JMX enabled? Check out amazonmq-cli.

alt text Here is a three minute video that shows how to install, configure and use ActiveMQ CLI.

Installation

Download activemq-cli in the release section of this repository.

Unzip the activemq-cli-x.x.x.zip file and configure the broker you want to connect to in activemq-cli-x.x.x/conf/activemq-cli.config:

broker {
  local {
    amqurl = "tcp://localhost:61616"
    jmxurl = "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi"
    username = ""
    password = ""
    prompt-color = "light-blue" 
  }

  // add additional brokers here
  dev {
    amqurl = "tcp://development-server:61616"
    jmxurl = "service:jmx:rmi:///jndi/rmi://development-server:1099/jmxrmi"
    username = "admin"
    password = "admin"		
  }	
  
  prod {
    amqurl = "tcp://production-server:61616"
    jmxurl = "service:jmx:rmi:///jndi/rmi://production-server:1099/jmxrmi"
  }	
  
  fuse-server {
    amqurl = "tcp://fuse-server:61616"
    jmxurl = "service:jmx:rmi:///jndi/rmi://fuse-server:1099/karaf-root"  
  }
  
  ssl-server {
    amqurl = "ssl://ssl-server:61616"
    jmxurl = "service:jmx:rmi:///jndi/rmi://ssl-server:1099/jmxrmi"
    
    // SSL 
    keyStore = "~/client.ks"
    keyStorePassword = "secret"
    trustStore = "~/client.ts"
  }  
}

Usage

To enter the activemq-cli shell run activemq-cli-x.x.x/bin/activemq-cli or activemq-cli-x.x.x/bin/activemq-cli.bat if you are using Windows.

activemq-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, activemq-cli also supports executing a file containing commands: activemq-cli --cmdfile my_commands.txt

To connect to a broker that is configured in activemq-cli-x.x.x/conf/activemq-cli.config: connect --broker dev

Below is a list of commands that activemq-cli supports.

add-queue

Adds a queue.

Parameters:
  • name

Example:add-queue --name foo

add-topic

Adds a topic.

Parameters:
  • name

Example:add-topic --name foo

connect

Connects activemq-cli to a broker.

Parameters:
  • broker (broker must be defined in activemq-cli-x.x.x/conf/activemq-cli.config)

Example:connect --broker local

copy-messages

Copies messages from a queue to another queue.

Parameters:
  • from
  • to
  • selector (copy messages that match the (JMS) selector)

Example:copy-messages --from foo --to bar

disconnect

Disconnects activemq-cli from the broker.

Example:disconnect

export-broker

Exports queues, topics and messages to file.

Parameters:
  • file

Example:export-broker --file broker.xml

For this command activemq-cli creates temporary mirror queues to ensure all messages are exported.

export-messages

Exports messages to file.

Parameters:
  • file
  • queue
  • selector (export messages that match the (JMS) selector)
  • regex (export messages whose body match the regex)

Example:export-messages --queue foo

For this command activemq-cli creates a temporary mirror queue to ensure all messages are exported.

info

Displays information (e.g. version, uptime, total number of queues/topics/messages) about the broker

Example:info

list-messages

Lists messages.

Parameters:
  • queue
  • selector (lists messages that match the (JMS) selector)
  • regex (lists messages whose body match the regex)

Example 1:list-messages --queue foo

Example 2:list-messages --queue foo --selector "JMSCorrelationID = '12345'"

Example 3:list-messages --queue foo --regex bar

For this command activemq-cli creates a temporary mirror queue to ensure all messages are listed.

list-queues

Lists queues.

Parameters:
  • filter (list queues with the specified filter in the name)
  • exclude-filter (list queues without the specified exclude-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

list-topics

Lists topics.

Parameters:
  • 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

move-messages

Moves messages from a queue to another queue.

Parameters:
  • from
  • to
  • selector (move messages that match the (JMS) selector)

pause-queue

Pauses a queues.

Parameters:
  • name
  • force (no prompt for confirmation)

Example:pause-queue --name foo

purge-all-queues

Purges all queues.

Parameters:
  • 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)
  • exclude-filter (list queues without the specified exclude-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

purge-queue

Purges a queues.

Parameters:
  • name
  • force (no prompt for confirmation)

Example:purge-queue --name foo

release-notes

Displays the release notes.

Example:release-notes

remove-all-queues

Removes all queues.

Parameters:
  • 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)
  • exclude-filter (list queues without the specified exclude-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

remove-all-topics

Removes all topics.

Parameters:
  • 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

remove-queue

Removes a queue.

Parameters:
  • name
  • force (no prompt for confirmation)

Example:remove-queue --name foo

remove-topic

Removes a topic.

Parameters:
  • name
  • force (no prompt for confirmation)

Example:remove-topic --name foo

resume-queue

Resumes a queues.

Parameters:
  • name
  • force (no prompt for confirmation)

Example:resume-queue --name foo

send-message

Sends a message or file of messages to a queue or topic.

Parameters:
  • 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)
  • type (not applicable if -file is specified)
  • 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>
      <type>myCustomType</type>
    </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

start-embedded-broker

Starts the embedded broker.

The embedded broker is configured in activemq-cli-x.x.x/conf/activemq-cli.config:

embedded-broker {
	connector = "tcp://localhost:61616"
	jmxport = 1099	
}

Example:start-embedded-broker

stop-embedded-broker

Stops the embedded broker.

Example:stop-embedded-broker