The blogger side Activemq is using the 5.13 version.
ACTIVEMQ open JMX or relatively simple
First of all, the way to start jmx without a password.
1. Modify the ACTIVEMQ. Configuration file for 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> <policyentrie s> <policyentry topic= ">" > <!--the Constantpendingmessagelimitstrateg
Y is used to prevent slow topic consumers to block producers and affect other consumers
By limiting the number of messages that is retained for more information, see:
Http://activemq.apache.org/slow-consumer-handling.html--
<pendingMessageLimitStrategy> <constantpendingmessagelimitstrategy limit= "/>" </pendingMessageLimitStrategy> </policyEntry> </POLICYENTRIES&G
T </policyMap> </destinationPolicy> <managementContext> <managementcontext <span style= "COLOR: #FF0000;" >createconnector= "true" connectorport= "1099" connectorhost= "192.168.157.128</span>"/> </management context> <persistenceAdapter> <kahadb directory= "${activemq.data}/kahadb"/> &L t;/persistenceadapter> <systemUsage> <systemUsage> <MEMORYUSAGE&G
T
<memoryusage percentofjvmheap= "/>" </memoryUsage> <storeUsage>
<storeusage limit= "GB"/> </storeUsage> <tempUsage>
<tempusage limit= "GB"/> </tempUsage> </systemUsage> </systemUsage> <transportConnectors> <!--DOS protection, limit concurrent Connect Ions to + 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&wirefo rmat.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>
Modify the red place above and then start MQ and start the JMX without the password.
ACTIVEMQ Java code access is as follows
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 {/** * get queue Size * * @return * @queueName queue name */Public Long GE Tqueuesize (String queuename) throws Exception {return Getremotejmxbrokerfacade (). Getqueue (queuename). getqueuesize
(); /** * Get Queue of consumers * * @return * @queueName queue name */public Long getconsumercount (String qu
Euename) throws Exception {return Getremotejmxbrokerfacade (). Getqueue (QueueName). Getconsumercount (); }/** * Get into Row message number * * @return * @queueName queue name */public Long getenqueuecount (String que
Uename) throws Exception {return Getremotejmxbrokerfacade (). Getqueue (QueueName). Getenqueuecount (); }/** * Get the number of DEQUEUE messages * * @return *@queueName Queue name */public Long Getdequeuecount (String queuename) throws Exception {return GETREMOTEJMXBR
Okerfacade (). Getqueue (QueueName). Getdequeuecount (); /** * Get Queue number * * @return * @queueName queue name */public int getqueuecount () throws Excepti
On {return Getremotejmxbrokerfacade (). Getqueues (). Size (); } private Remotejmxbrokerfacade Getremotejmxbrokerfacade () throws Exception {Remotejmxbrokerfacade Createcon
Nector = null;
try {createconnector = new Remotejmxbrokerfacade (); Fill in the Link Properties system.setproperty ("Webconsole.jmx.url", "service:jmx:rmi:///jndi/rmi://" + activemqconfig.get (Activ
EMQCONFIG.IP) + ":" + activemqconfig.get (activemqconfig.port) + "/jmxrmi");
System.setproperty ("Webconsole.jmx.user", "admin");
System.setproperty ("Webconsole.jmx.password", "admin"); Create Configuration Systempropertiesconfiguration configuration = new systempropertiesconfiguration ();
Create a link createconnector.setconfiguration (configuration);
} catch (Exception e) {e.printstacktrace ();
throw new Exception ("JMX link Failed");
} return createconnector;
}
}
Access results are as follows