Tuesday, 8 December 2015

Embed your ActiveMQ broker within your Wildfly (JBoss) JVM

This post is intended for ActiveMQ 5.11 and WildFly (JBoss) 8.2

It is possible to launch the JMS broker inside the JVM of Wildfly so no need to set up a different ActiveMQ server.



All I did is just change the transport protocol inside standalone.xml



From
                        tcp://localhost:61616?jms.rmIdFromConnectionId=true

                   

To :

                 
                      vm://localhost?broker.persistent=false

                   

It is important to set the persistence to false as to avoid persistence configuration. In addtion, one can also set the ActiveMQ configuration file with the parameter brokerConfig=xbean:activemq.xml
Monitoring the JMS queues



Now that the ActiveMQ console is down you probably wonder how can you check the queues. You can do it by connection to JMX environment of the Wildfly JVM.

You have two options :

    Use the ActiveMQ web console
    Use JConsole


1. Use the ActiveMQ web console


To enable  the ActiveMQ console in Wildfly, just two steps are needed:

    Set the JVM system parameters in standalone.xml to inform the ActiveMQ console application to connect through JMX. Add the following JVM system parameters under the extensions tag:

    <server name="xyz.home" xmlns="urn:jboss:domain...">
    <extensions>
   
    </extensions>
 
   <system-properties>
        
        <property name="webconsole.type" value="properties"/>
        <property name="webconsole.jms.url" value="vm://localhost"/>
        <property name="webconsole.jmx.url" value="service:jmx:http-remoting-jmx://localhost:9990"/>
       
     </system-properties>
     

       
   
           
           
           
       




    Deploy the ActiveMQ console war.  This war contains the jboss-client.jar (under /lib). You can download it here

Make sure you delete the line specifying kaha db persistence from webconsole-embedded.xml

In activemq.xml, change the broker name to (so your console and wildfly point to the same object) :

  <broker brokerName="localhost" useJmx="true" xmlns="http://activemq.apache.org/schema/core">


     The ActiveMQ should be running under this WildFly context
               

      http://localhost:8080/activemq-web-console-5.11.1/



2. Use JConsole


Just use JConsole by adding into its classpath the jar jboss-cli-client.jar. I have added bat file to run jconsole on Windows. Just set JAVA_HOME and JBOSS_JAR.



set JAVA_HOME=

set JBOSS_JAR=



%JAVA_HOME%\bin\jconsole -J-Djava.class.path=%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\jconsole.jar;%JBOSS_JAR%\jboss-cli-client.jar"







On the new connection in JConsole, choose Remote process. Set value as :


service:jmx:http-remoting-jmx://localhost:9990



username : your_admin_username

password : your_admin_password



A few tabs will appear.



Go to MBeans tab, org.apache.activeMQ sub tree will appear on the left side.



About Me

My Photo