ActiveMQ官方文档翻译-命令行工具指南

当前的脚本包含了所有管理activemq的功能。

在5.4.1之前的版本,一些超过了控制服务本身的管理功能被包含在"activemq-admin"脚本当中。

这个脚本现在仍有部分提供给了windows用户使用

在5.0之前的版本这些管理消息中间件的脚本(activemq-admin)被分割为多个脚本,如:

  • shutdown - 停止消息中间件

  • list - 列出所有在指定的JMX上下文内的正在运行的消息中间件

  • query - 查询统计和信息

  • bstat - predefined query that displays useful broker statistics

  • browse - 浏览指定队列的信息

  • purge - 删除与消息选择器匹配的消息

activemq脚本

注:这个脚本只能用在windows平台以及5.4.0版本之前的unix平台。5.4.0及以后的版本activemq提供了一个加强版的unix shell脚本

脚本名称activemq.bat, activemq
使用方式activemq [options] [config] or java -jar run.jar start [options] [config]
描述

用于启动activemq消息中间件的脚本,该脚本即可以通过指定一个配置文件也可以通过URI配置的方式来运行

选项:

选项名称
语法例子描述
系统定义的选项
-D<key>=<value>-Dactivemq.home=c:/ActiveMQ设置系统属性。比如这个例子中当在代码中调用Systems.getProperty("activemq.home")时会返回c:/ActiveMQ
帮助选项
-h or -? or --helpactivemq --help显示activemq脚本的帮助信息
版本信息选项
--versionactivemq --version显示activemq的版本信息

例子:

例子
描述
activemq

使用默认的'xbena:activemq.xml‘配置文件启动消息中间件

activemq xbean:myconfig.xml

使用在classpath下的myconfig.xml文件作为配置文件启动消息中间件

activemq xbean:file:./conf/broker1.xml

使用在相对路径./conf/broker1.xml下的broker1.xml文件作为配置文件启动消息中间件

activemq xbean:file:C:/ActiveMQ/conf/broker2.xml

使用绝对路径C:/ActiveMQ/conf/下的broker2.xml文件作为配置文件启动消息中间件。

activemq broker:(tcp://localhost:61616,tcp://localhost:5000)?useJmx=true

使用url的方式来启动消息中间件,这个例子中启动了两个传输通道(分别在61616和5000端口上监听)并且启用了jmx特性。

activemq broker:(tcp://localhost:61616,network:tcp://localhost:5000)?persistent=false

Runs a broker with 1 transport connector and 1 network connector with persistence disabled.Â

使用url的方式来启动消息中间件,这个例子中启动了1个传输通道(在61616端口上监听)和一个网络通道(在5000端口监听)并且明确禁用了持久化特性。

(译者注:在5.11.1及后的版本中上面的这些例子在activemq后要增加一个start参数,如activemq start xbean:myconfig.xml,并且要特别注意url参数不能有空格,在官方提供的原文档中多个地方中间有空格导致执行不成功)

更多有关配置和使用broker URI的信息可参看:Broker Configuration URI

activemq-admin

ActiveMQ 5.x版本以后,上面那些单独的脚本都被并入到activemq-admin当中(除了active脚本外),如下:

  • activemq-admin stop

  • activemq-admin list

  • activemq-admin query

  • activemq-admin bstat

  • activemq-admin browse

每个任务的语法如下所述。要注意的是activemq这个命令还是保留的。

stop task

任务名称stop
使用方法
activemq-admin stop [options] [broker names]
描述用来停止一个正在运行的消息中间件。这个任务能执行的前提是在启动消息中间件时开启了jmx特性

选项

选项名称
语法例子描述
停止所有选项
--allstop --all停止所有被注册在指定的jmx上下文内的消息中间件
JMX URL--jmxurl <url> --jmxurl service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
JMX Authentication--jmxuser user --jmxpassword password--jmxuser smx --jmxpassword smx
System Define-D<key>=<value> -Dactivemq.home=c:/ActiveMQ
Help-h or -? or --help--help
Version--versionactivemq --version

例子

例子
描述
activemq-admin stop停止默认的jmx上下文内正在运行的消息中间件。假设只有一个正在运行的消息中间件
activemq-admin stop --jmxurl service:jmx:rmi:///jndi/rmi://remotehost:1099/jmxrmi --all停止所有在指定的jmx上下文内的下在运行的消息中间件
activemq-admin stop localhost停止在默认的jmx上下文内正在运行的叫'localhost'的消息中间件
activemq-admin stop localhost remotehost停止在默认的jmx上下文内正在运行的叫'localhost'和'remotehost'的消息中间件

list task

任务名称list
使用方法
activemq-admin list [options]
描述列出在指定的jmx上下文内运行的所有正在运行的消息中间件的名字。这个任务能执行的前提是在启动消息中间件时开启了jmx特性

选项

选项名称语法例子描述
JMX URL --jmxurl <url> --jmxurl service:jmx:rmi:///jndi/rmi://remotehost:1099/jmxrmi
JMX Authentication--jmxuser user --jmxpassword password--jmxuser smx --jmxpassword smx
System Define-D<key>=<value> -Dactivemq.home=c:/ActiveMQ 
Help-h or -? or --help --help
Version--versionactivemq --version

例子

例子描述
activemq-admin list列出默认的jmx上下文内所有正在运行的消息中间件的名称
activemq-admin list --jmxurl service:jmx:rmi:///jndi/rmi://remotehost:1099/jmxrmi列出指定的jmx上下文内所有正在运行的消息中间件的名称

query task

任务名称query
使用方法
activemq-admin query [options]
描述Script to query the specified JMX context for mbean attributes and information。这个任务能执行的前提是在启动消息中间件时开启了jmx特性

选项

选项名称语法例子描述
Predefined Query Option-Q<type>=<name>-QTopic=TEST.FOO, -QBroker=*host预定义对象名称查询选项,查询基于其类型和选择特定的MBean对象类型标识符。具体请参考下面给出的mbean参考表格。

-xQ<type>=<name>-xQTopic=ActiveMQ.Advisory.*, -xQNetworkConnector=*预定义对象名称查询选项,不显示所有匹配的查询的搜索结果MBeans。具体请参考下面给出的mbean参考表格。
Object Name Query Option--objname <object name query>--objname Type=Connect,BrokerName=local*格式不严格的基于JMX对象名称格式的查询选项,它可以让你过滤基于对象名称信息MBean。具体请参考下面给出的mbean参考表格。

--xobjname <object name query>--xobjname Type=Topic,Destination=ActiveMQ.Advisory.*对象名称查询,在搜索结果中不显示所有匹配查询选项的mbean。具体请参考下面给出的mbean参考表格。
View Option--view <view list>--view Type,BrokerName,Destination,EnqueueCount,DequeueCount让你可以指定对象和属性名称来查看信息。如果view后没有选项则会显示所有的信息。

例子

例子
描述
activemq-admin query显示所有在默认的jmx上下文中注册的mbean的所有属性和对象名。
activemq-admin query -QTopic=TEST.FOO显示所有目的主题名称为TEST.FOO的所有属性和对象名。
activemq-admin query -QQueue=*显示所有注册队列的所有属性和对象名。
activemq-admin query -QTopic=*.FOO -xQTopic=ActiveMQ.Advisory.*显示所有主题名称以'.FOO'结尾的并且不以''ActiveMQ.Advisory.'开头的所有属性和对象名。
activemq-admin query -QBroker=local???? --view Type,BrokerName,EnqueueCount,DequeueCount显示所有消息中间件的名称为9个字母的并且以'local'开头的对象类型,中间件名称,入队列数据的数目,出队列数据的数目信息。
activemq-admin query --objname Type=Connect,BrokerName=localhost -xQNetworkConnector=*显示名字为'localhost'的消息中间件的所有的连接和连接器的所有属性和对象名称(除了网络连接器)。
activemq-admin query --objname Type=Connection --xobjname Type=Connection,BrokerName=localhost显示所有已注册的连接的所有属性和对象名称信息(除了那些属于名字为'localhost’的broker的)。
activemq-admin query -QQueue=???? --objname Type=Connection --xobjname BrokerName=remote*显示所有名字为四个字母的队列和连接的所有的属性和对象名称的信息(除了那些属于以'remote'开头的消息中间件的)。

ActiveMQ MBean 参考

MBean类型属性/对象名属性
Broker
  • Type=Broker

  • BrokerName=<broker identifier>

  • BrokerId

  • TotalEnqueueCount

  • TotalDequeueCount

  • TotalConsumerCount

  • TotalMessages

  • TotalMessagesCached

  • MemoryLimit

  • MemoryPercentageUsed

Destination
  • Type=Queue|Topic

  • Destination=<destination identifier>

  • BrokerName=<name of broker>

  • EnqueueCount

  • DequeueCount

  • ConsumerCount

  • Messages

  • MessagesCached

NetworkConnector
  • Type=NetworkConnector

  • BrokerName=<connector identifierr>


Connector
  • Type=Connector

  • ConnectorName=<connector identifier>

  • BrokerName=<name of broker>

  • EnqueueCount

  • DequeueCount

Connection
  • Type=Connection

  • Connection=<connection identifier>

  • BrokerName=<name of broker>

  • EnqueueCount

  • DequeueCount

  • DispatchQueueSize

  • Active

  • Blocked

  • Connected

  • Slow

bstat task

任务名称bstat
使用方法activemq-admin bstat [broker name]
描述显示对消息中间件及它的组件有用的统计的预定义脚本。

例子

例子描述
activemq-admin bstat显示默认的jmx上下文中所有注册的消息中间件的有用的统计信息。
activemq-admin bstat localhost显示注册的名字叫'localhost'的消息中间件的有用的统计信息

browse task

任务名称
browse
使用方法activemq-admin browse --amqurl <broker url> [options] <destinations> or java -jar run.jar browse --amqurl <broker url> [options] <destinations>
描述用来浏览选中的目的消息的脚本

选项

选项名称表达式例子描述
Broker URL--amqurl <url> --amqurl tcp://localhost:61616指定要连接的broker URL
消息选择器--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.
视图组-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.
指定的视图--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.

例子

例子
描述
activemq-admin browse --amqurl tcp://localhost:61616 TEST.FOO打印所有在名字叫'TEST.FOO'的队列里的消息的JMS消息头,自定义消息头和消息体
activemq-admin browse --amqurl tcp://localhost:61616 -Vheader,body TEST.FOO打印所有在名字叫'TEST.FOO'的队列里的消息的JMS消息头和消息体
activemq-admin browse --amqurl tcp://localhost:61616 -Vheader --view custom:MyCustomField TEST.FOO TEST.BAR打印所有在名字叫'TEST.FOO'和'TEST.BAR'的队列里的消息的JMS消息头和自定义字段'MyCustomField'
activemq-admin browse --amqurl tcp://localhost:61616 --msgsel "JMSMessageID='*:10',JMSPriority>5" TEST.FOO打印所有在队列'TEST.FOO'里的所有消息里的JMSMessageID能够模糊匹配'*:10'的以及JMSPriority(消息优先级)大于5的消息属性。 

JMS消息头参考

消息头名称
消息头类别
JMSCorrelation IDString
JMSDelivery Modeint (1-Non-Persistent, 2-Persistent)
JMSDestinationjavax.jms.Destination
JMSExpirationlong
JMSMessageIDString
JMSPriorityint
JMSRedeliveredboolean
JMSReplyTojavax.jms.Destination
JMSTimestamplong

JMSTypeString

purge task

任务名称purge
使用方法activemq-admin purge [purge-options] <destinations>
描述删除匹配消息选择器的所有目的消息

选项

选项名称
表达式例子描述
JMX URL--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--jmxuser user --jmxpassword password--jmxuser smx --jmxpassword smxFor cases where username/password based authentication of the JMX client is required. Not set by default
消息选择器--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.

例子

例子描述
activemq-admin purge FOO.BAR删除所有在队列'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

任务名称
dstat
使用方法activemq-admin dstat [destination type]
描述用来显示对于一个消息中间件有用的统计信息的脚本

例子

例子描述
activemq-admin dstat显示在默认的jmx上下文中所有的在消息中间件中的目的消息的有用统计信息
activemq-admin dstat topics显示所有在消息中间件中的主题的有用的统计信息

原文链接

ActiveMQ Command Line Tools Reference

转载于:https://my.oschina.net/u/914897/blog/425017

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值