layout: default_md title: ActiveMQ Command Line Tools Reference title-class: page-title-activemq5 type: activemq5

 FAQ > Using Apache ActiveMQ > ActiveMQ Command Line Tools Reference

Command Line Tools

The current script contains the entire functionality to manage activemq.

In versions prior 5.4.1 some management functionalities beyond controlling the service itself where part of the “activemq-admin” script.
This script is currently still part of the distribution to provide access to this for Windows users-

In versions prior to 5.0 the functionality of activemq-admin script was scattered over multiple scripts, such as:

  • shutdown - shutdowns an activemq broker
  • list - lists all running brokers in the specified JMX context
  • query - queries the JMX context for broker statistics and information
  • bstat - predefined query that displays useful broker statistics
  • browse - browse the messages of a specific queue
  • purge - delete selected destination's messages that matches the message selector

activemq script

Description of this script is valid for Windows platform. For Unix platform it is valid for broker versions prior to 5.4.0. With version 5.4.0 and later, ActiveMQ comes with enhanced Unix Shell Script

Script Name|activemq.bat, activemq Task Usage|activemq [options] [config] or java -jar run.jar start [options] [config] Description|Script to run an activemq broker either by specifying a broker configuration file or through a broker URI configuration.

Options:

Option NameSyntaxExampleDescription
System Define Option-D=-Dactivemq.home=c:/ActiveMQSets a systems property. i.e Systems.getProperty(“activemq.home”); will return c:/ActiveMQ
Help Option-h or -? or --helpactivemq --helpDisplay the help messages for the activemq script.
Version Option--versionactivemq --versionDisplay the activemq version information.

Examples:

ExampleDescription
activemqRuns a broker using the default ‘xbean:activemq.xml’ as the broker configuration file.
activemq xbean:myconfig.xmlRuns a broker using the file myconfig.xml as the broker configuration file that is located in the classpath.
activemq xbean:file:./conf/broker1.xmlRuns a broker using the file broker1.xml as the broker configuration file that is located in the relative file path ./conf/broker1.xml
activemq xbean:file:C:/ActiveMQ/conf/broker2.xmlRuns a broker using the file broker2.xml as the broker configuration file that is located in the absolute file path C:/ActiveMQ/conf/broker2.xml
activemq broker:(tcp://localhost:61616, tcp://localhost:5000)?useJmx=trueRuns a broker with two transport connectors and JMX enabled.¹
activemq broker:(tcp://localhost:61616, network:tcp://localhost:5000)?persistent=falseRuns a broker with 1 transport connector and 1 network connector with persistence disabled.¹

For details on how to configure using broker URI refer to: Broker Configuration URI

activemq-admin

As of ActiveMQ 5.x, the above standalone utilities have been incorporated into the activemq-admin command (with the exception of the activemq script), as follows:

The syntax of each task remains as described below. Note also that the activemq command is still supported.

stop task

Task Name|stop Task Usage|activemq-admin stop [options] [broker names] Description|Script to stop a running activemq broker. This task requires that JMX is enabled.

Options:

Option NameSyntaxExampleDescription
Stop All Option--allstop --allStops all registered brokers in the specified JMX context
JMX URL Option--jmxurl --jmxurl service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmiChange the JMX service url to connect to. By default it connects to: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
JMX Authentication Option--jmxuser user --jmxpassword password--jmxuser smx --jmxpassword smxFor cases where username/password based authentication of the JMX client is required. Not set by default.
System Define Option-D=-Dactivemq.home=c:/ActiveMQSets a systems property. i.e Systems.getProperty(“activemq.home”); will return c:/ActiveMQ
Help Option-h or -? or --help--helpDisplay the help messages for the stop script.
Version Option--versionactivemq --versionDisplay the activemq version information.

Examples:

ExampleDescription
activemq-admin stopStops the only running broker in the default JMX context. It assumes that there is only one running broker.
activemq-admin stop --jmxurl service:jmx:rmi:///jndi/rmi://remotehost:1099/jmxrmi --allStops all the running broker in the specified JMX context.
activemq-admin stop localhostStops the broker named ‘localhost’ in the default JMX context.
activemq-admin stop localhost remotehostStops the brokers ‘localhost’ and ‘remotehost’ in the default JMX context.

list task

Task Name|list Task Usage|activemq-admin list [options] Description|Script to list the names of all running brokers in the specified JMX context. This task requires that JMX is enabled.

Options:

Option NameSyntaxExampleDescription
JMX URL Option--jmxurl --jmxurl service:jmx:rmi:///jndi/rmi://remotehost:1099/jmxrmiChange the JMX service url to connect to. By default it connects to: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
JMX Authentication Option--jmxuser user --jmxpassword password--jmxuser smx --jmxpassword smxFor cases where username/password based authentication of the JMX client is required. Not set by default.
System Define Option-D=-Dactivemq.home=c:/ActiveMQSets a systems property. i.e Systems.getProperty(“activemq.home”); will return c:/ActiveMQ
Help Option-h or -? or --help--helpDisplay the help messages for the list script.
Version Option--versionactivemq --versionDisplay the activemq version information.

Examples:

ExampleDescription
activemq-admin listLists the names of all running brokers in the default JMX context.
activemq-admin list --jmxurl service:jmx:rmi:///jndi/rmi://remotehost:1099/jmxrmiList the names of all running brokers in the specified JMX context.

query task

Task Name|query Task Usage|activemq-admin query [options] Description|Script to query the specified JMX context for mbean attributes and information. This script requires that JMX is enabled.

Options:

Option NameSyntaxExampleDescription
Predefined Query Option-Q<type>=<name>-QTopic=TEST.FOO, -QBroker=*hostPredefined object name query option that queries a specific type of mbean object based on its type and selected identifier. Refer to the mbean reference table below for details.
-xQ<type>=<name>-xQTopic=ActiveMQ.Advisory., -xQNetworkConnector=Predefined object name query option that removes all mbeans that matches the query from the search result. Refer to the mbean reference table below for details.
Object Name Query Option--objname <object name query>--objname Type=Connect,BrokerName=local*Query option loosely based on the JMX object name format, which lets you filter mbeans based on their object name information. Refer to the mbean reference table below for details.
--xobjname <object name query>--xobjname Type=Topic,Destination=ActiveMQ.Advisory.*Object name query that removes all mbeans that matches the query from the search result. Refer to the mbean reference table below for details.
View Option--view <view list>--view Type,BrokerName,Destination,EnqueueCount,DequeueCountLets you specify the attributes and object name information to view. If the view is omitted, all attributes and information will be displayed.
JMX URL Option--jmxurl <url>--jmxurl service:jmx:rmi:///jndi/rmi://remotehost:1099/jmxrmiChange the JMX service url to connect to. By default it connects to: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
JMX Authentication Option--jmxuser user --jmxpassword password--jmxuser smx --jmxpassword smxFor cases where username/password based authentication of the JMX client is required. Not set by default.
System Define Option-D<key>=<value>-Dactivemq.home=c:/ActiveMQSets a systems property. i.e Systems.getProperty(“activemq.home”); will return c:/ActiveMQ
Help Option-h or -? or --help--helpDisplay the help messages for the query script.
Version Option--versionactivemq --versionDisplay the activemq version information.

Examples:

ExampleDescription
activemq-admin queryDisplay all attributes and object name information of all registered mbeans in the default JMX context.
activemq-admin query -QTopic=TEST.FOODisplay all the attributes and object name information of the destination topic ‘TEST.FOO’
activemq-admin query -QQueue=*Display all the attributes and object name information of all registered queues.
activemq-admin query -QTopic=.FOO -xQTopic=ActiveMQ.Advisory.Display all the attributes and object name information of all topics that ends with ‘.FOO’ except those that also begins with ‘ActiveMQ.Advisory.’.
activemq-admin query -QBroker=local???? --view Type,BrokerName,EnqueueCount,DequeueCountDisplay the object type, broker name, enqueue count, and dequeue count information for all 9-letter brokers that begins with ‘local’.
activemq-admin query --objname Type=Connect,BrokerName=localhost -xQNetworkConnector=*Display all the attributes and object name information for all connections and connectors for broker ‘localhost’ except its network connectors.
activemq-admin query --objname Type=Connection --xobjname Type=Connection,BrokerName=localhostDisplay all the attributes and object name information for all registered connections except those belonging to broker ‘localhost’.
activemq-admin query -QQueue=???? --objname Type=Connection --xobjname BrokerName=remote*Display all the attributes and object name information for all 4-letter queues and connections except those belonging to a broker that begins with ‘remote’.

ActiveMQ MBean Reference:

Mbean TypeProperties / ObjectName AttributesOperations
Brokertype=Broker, brokerName=<broker-identifier>BrokerId, TotalEnqueueCount, TotalDequeueCount, TotalConsumerCount, TotalMessageCount, TotalConnectionsCount, TotalConsumerCount, TotalProducerCount, MemoryLimit, MemoryPercentUsage, StoreLimit, StorePercentUsagestart, stop, terminateJVM, resetStatistics, gc
Destinationtype=Broker, brokerName=<name-of-broker>, destinationType=Queue|Topic, destinationName=<name>Average, EnqueueTime, ConsumerCount, DequeueCount, EnqueueCount, ExpiredCount, InFlightCount, MemoryLimit, MemoryPercentUsage, Name, QueueSize (queues only)browseMessages, gc, purge, resetStatistics
NetworkConnectortype=Broker, brokerName==<name-of-broker>, connector=networkConnectors, networkConnectorName==<connector-identifier>Name, Duplex, DynamicOnly, BridgeTempDestinations, ConduitSubscriptions, DecreaseNetworkConsumerPriority, DispatchAsync, DynamicOnly, NetworkTTL, Password, PrefetchSizestart, stop
Connectortype=Broker, brokerName=<name-of-broker>, connector=clientConnectors, ConnectorName==<connector-identifier>StatisticsEnabledstart, stop, resetStatistics, enableStatistics, disableStatistics, connectionCount
Connectiontype=Broker, brokerName=<name-of-broker>, connectionViewType=clientId, connectionName==<connection-identifier>DispatchQueueSize, Active, Blocked, Connected, Slow, Consumers, Producers, RemoteAddress, UserName, ClientIdstart, stop, resetStatistics
PersistenceAdaptertype=Broker, brokerName=<name-of-broker>, Service=PersistenceAdapter, InstanceName==<adapter-identifier>Name, Size, Data, Transactions
Healthtype=Broker, brokerName=<name-of-broker>, Service=HealthCurrentStatushealth

bstat task

Task Name|bstat Task Usage|activemq-admin bstat [broker name] Description|Predefined query script that displays useful statistics regarding a broker and its components.

Examples:

ExampleDescription
activemq-admin bstatDisplay useful statistics for all registered brokers in the default JMX context.
activemq-admin bstat localhostDisplay useful statistics for the registered broker ‘localhost’.

browse task

Task Name|browse Task Usage|activemq-admin browse --amqurl <broker url> [options] <destinations> or java -jar run.jar browse --amqurl <broker url> [options] <destinations> Description|Script to browse selected destinations' messages.  The browse operation may not return all messages due to limitations of broker configuration and system resources.

Options:

Option NameSyntaxExampleDescription
Broker URL Option--amqurl <url>--amqurl tcp://localhost:61616Specify the broker URL to connect to.
Message Selector Option--msgsel “<msgsel1,msgsel2,...>”--msgsel “JMSMessageID=‘*:10’,JMSPriority>5”Allows you to filter the specific messages to view. Place the entire selector criteria in double quotes " ". You can use wildcard queries by enclosing the string message property in ' '. Other than using wildcard queries to filter string properties, other queries follows the message selector format.
Group View Option-V[header | custom | body]-Vheader, -Vcustom, -VbodyLet's you specify a specific group of message attributes to view. The header view shows all the standard JMS message headers. The custom view shows all the custom fields added to each JMS message. The body view shows the message body of the JMS message.
Specific View Option--view <attr1>,[header:|custom:]<attr2>,...--view JMSMessageID=‘*:10’,custom:MyCustomFieldLet's you specifically select a specific message attribute. It allows you to select specific attributes from the JMS and custom headers. You could add the tags header: and custom: to explicitly specify where the attribute belongs to. Refer to the message header table below for details.
System Define Option-D<key>=<value>-Dactivemq.home=c:/ActiveMQSets a systems property. i.e Systems.getProperty(“activemq.home”); will return c:/ActiveMQ
Help Option-h or -? or --help--helpDisplay the help messages for the browse script.
Version Option--versionactivemq --versionDisplay the activemq version information.

Examples:

ExampleDescription
activemq-admin browse --amqurl tcp://localhost:61616 TEST.FOOPrints the JMS message header, custom message header, and message body of the messages in the queue ‘TEST.FOO’
activemq-admin browse --amqurl tcp://localhost:61616 -Vheader,body TEST.FOOPrints the JMS message header and message body of the messages in the queue ‘TEST.FOO’
activemq-admin browse --amqurl tcp://localhost:61616 -Vheader --view custom:MyCustomField TEST.FOO TEST.BARPrints all the JMS message header and the custom field ‘MyCustomField’ of the messages in the queue ‘TEST.FOO’ and ‘TEST.BAR’.
activemq-admin browse --amqurl tcp://localhost:61616 --msgsel “JMSMessageID=‘*:10’,JMSPriority>5” TEST.FOOPrints all the attributes of the messages in the queue ‘TEST.FOO’ that has a JMSMessageID that matches the wildcard query *:10 and has a JMSPriority greater than 5.

JMS Message Header Reference:

Header NameHeader Type
JMSCorrelation IDString
JMSDelivery Modeint (1-Non-Persistent, 2-Persistent)
JMSDestinationjavax.jms.Destination
JMSExpirationlong
JMSMessageIDString
JMSPriorityint
JMSRedeliveredboolean
JMSReplyTojavax.jms.Destination
JMSTimestamplong
JMSTypeString

purge task

Task Name|purge Task Usage|activemq-admin purge [purge-options] Description|Delete selected destination's messages that matches the message selector.

Options:

Option NameSyntaxExampleDescription
JMX URL Option--jmxurl <url>--jmxurl service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmiChange the JMX service url to connect to. By default it connects to: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
JMX Authentication Option--jmxuser user --jmxpassword password--jmxuser smx --jmxpassword smxFor cases where username/password based authentication of the JMX client is required. Not set by default.
Message Selector Option--msgsel “<msgsel1,msgsel2,...>”--msgsel “JMSMessageID=‘*:10’,JMSPriority>5”Allows you to filter the specific messages to view. Place the entire selector criteria in double quotes " ". You can use wildcard queries by enclosing the string message property in ' '. Other than using wildcard queries to filter string properties, other queries follows the message selector format.
System Define Option-D<key>=<value>-Dactivemq.home=c:/ActiveMQSets a systems property. i.e Systems.getProperty(“activemq.home”); will return c:/ActiveMQ
Help Option-h or -? or --help--helpDisplay the help messages for the browse script.
Version Option--versionactivemq --versionDisplay the activemq version information.

Examples:

Example|Description| activemq-admin purge FOO.BAR|Delete all the messages in queue FOO.BAR activemq-admin purge --msgsel “JMSMessageID=‘*:10’,JMSPriority>5” FOO.|Delete all the messages in the destinations that matches FOO. and has a JMSMessageID in", the header field that matches the wildcard *:10, and has a JMSPriority field > 5 in the", queue FOO.BAR. To use wildcard queries, the field must be a string and the query enclosed in ''

dstat task

Task Name|dstat Task Usage|activemq-admin dstat [destination type] Description|Predefined query script that displays useful statistics regarding destinations on a broker.

Examples:

ExampleDescription
activemq-admin dstatDisplay useful statistics for all destinations on the broker in the default JMX context.
activemq-admin dstat topicsDisplay useful statistics for the Topics that currently exist on the Broker.