ACTIVEMQ Open JMX

Source: Internet
Author: User
Tags stomp xmlns

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&gt
  ;
          <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> &LT;/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> &LT;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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.