activemq开启 jmx
来源:互联网 发布:天天pk10计划软件 编辑:程序博客网 时间:2024/05/01 18:40
博主这边activemq使用的是5.13的版本
activemq开启jmx还是相对简单的
首先说说不用密码的的方式开始jmx
1.修改activemq。xml的配置文件
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>file:${activemq.conf}/credentials.properties</value> </property> </bean> <bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery" lazy-init="false" scope="singleton" init-method="start" destroy-method="stop"> </bean> <broker xmlns="http://activemq.apache.org/schema/core"<span style="color:#FF0000;"><strong> useJmx="true"</strong></span> brokerName="localhost" dataDirectory="${activemq.data}"> <destinationPolicy> <policyMap> <policyEntries> <policyEntry topic=">" > <!-- The constantPendingMessageLimitStrategy is used to prevent slow topic consumers to block producers and affect other consumers by limiting the number of messages that are retained For more information, see: http://activemq.apache.org/slow-consumer-handling.html --> <pendingMessageLimitStrategy> <constantPendingMessageLimitStrategy limit="1000"/> </pendingMessageLimitStrategy> </policyEntry> </policyEntries> </policyMap> </destinationPolicy> <managementContext> <managementContext <span style="color:#FF0000;">createConnector="true" connectorPort="1099" connectorHost="192.168.157.128</span>"/> </managementContext> <persistenceAdapter> <kahaDB directory="${activemq.data}/kahadb"/> </persistenceAdapter> <systemUsage> <systemUsage> <memoryUsage> <memoryUsage percentOfJvmHeap="70" /> </memoryUsage> <storeUsage> <storeUsage limit="100 gb"/> </storeUsage> <tempUsage> <tempUsage limit="50 gb"/> </tempUsage> </systemUsage> </systemUsage> <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> <transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> </transportConnectors> <shutdownHooks> <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /> </shutdownHooks> </broker> <import resource="jetty.xml"/></beans>修改上面的红色的地方 然后启动mq就开始不用密码的jmx了
activemq java代码访问如下
import com.yihu.ehr.mqhelper.config.ActiveMQConfig;import org.apache.activemq.web.RemoteJMXBrokerFacade;import org.apache.activemq.web.config.SystemPropertiesConfiguration;/** * Created by chenweida on 2015/12/19. */class ActiveMQJMSHelper { /** * 得到队列大小 * * @return * @queueName 队列名字 */ public Long getQueueSize(String queueName) throws Exception { return getRemoteJMXBrokerFacade().getQueue(queueName).getQueueSize(); } /** * 得到队列的消费者 * * @return * @queueName 队列名字 */ public Long getConsumerCount(String queueName) throws Exception { return getRemoteJMXBrokerFacade().getQueue(queueName).getConsumerCount(); } /** * 得到入列消息数量 * * @return * @queueName 队列名字 */ public Long getEnqueueCount(String queueName) throws Exception { return getRemoteJMXBrokerFacade().getQueue(queueName).getEnqueueCount(); } /** * 得到出列消息数量 * * @return * @queueName 队列名字 */ public Long getDequeueCount(String queueName) throws Exception { return getRemoteJMXBrokerFacade().getQueue(queueName).getDequeueCount(); } /** * 得到队列数 * * @return * @queueName 队列名字 */ public int getQueueCount() throws Exception { return getRemoteJMXBrokerFacade().getQueues().size(); } private RemoteJMXBrokerFacade getRemoteJMXBrokerFacade() throws Exception { RemoteJMXBrokerFacade createConnector = null; try { createConnector = new RemoteJMXBrokerFacade(); // 填写链接属性 System.setProperty("webconsole.jmx.url", "service:jmx:rmi:///jndi/rmi://" + ActiveMQConfig.get(ActiveMQConfig.IP) + ":" + ActiveMQConfig.get(ActiveMQConfig.PORT) + "/jmxrmi"); System.setProperty("webconsole.jmx.user", "admin"); System.setProperty("webconsole.jmx.password", "admin"); // 创建配置 SystemPropertiesConfiguration configuration = new SystemPropertiesConfiguration(); // 创建链接 createConnector.setConfiguration(configuration); } catch (Exception e) { e.printStackTrace(); throw new Exception("jmx链接失败"); } return createConnector; }}
访问结果如下
1 0
- activemq开启 jmx
- ActiveMQ+JMX
- 利用JMX监控ActiveMQ
- JMX操作ActiveMQ(1)
- JMX操作ActiveMQ(2)
- Java监控activeMQ(JMX)
- activeMQ monitoring using JMX
- ActiveMq Jmx消息提取
- JMX操作ActiveMQ(1)
- jmx监控activemq
- Tomcat,JVM开启JMX
- resin4开启jmx
- tomcat开启jmx
- tomcat开启jmx 验证
- 服务器开启JMX监控
- Linux Tomcat 开启 JMX
- Ehcache开启JMX支持
- Tomcat开启JMX监控
- Spring学习详解(1)——Spring入门详解
- python Item_CF
- bootstrap导入JavaScript插件
- 黑马程序员--OC自学笔记---05点语法、@property、@synthesize、动态类型、id类型、响应方法、构造方法
- 2015私人阅读十五佳
- activemq开启 jmx
- MRATgent是什么? CleanMyMac每天提示没有响应
- python UserBasedCF
- FileUpload——在Struts2中上传文件
- linux常用命令 hostname,rsync文件同步,ping
- 关于火狐双击无法启动只有进程的问题的解决方案
- Java学习--最大公约数 && 最小公倍数
- 20151230 远程部署成功,但访问时出现404错误
- C++访问ORACLE数据库