Google+ Followers

Monday, June 29, 2015

Connecting jvisualvm to JBoss EAP 6.2 on Windows

In case you want to use jvisualvm to connect up to JBoss EAP 6.2 on Windows, you can use the following script (which should be placed into JBOSS_HOME/bin as jvisualvm.bat):
@echo off  
rem -------------------------------------------------------------------------  
rem jvisualvm script for Windows  
rem -------------------------------------------------------------------------  
rem  
rem A script for running jvisualvm with the remoting-jmx libraries on the classpath.  
  
rem $Id$  
  
@if not "%ECHO%" == ""  echo %ECHO%  
@if "%OS%" == "Windows_NT" setlocal  
  
if "x%JAVA_HOME%" =="x" (  
    echo JAVA_HOME environment variable has not been set - please set and re-run!  
    goto :EOF  
)  
  
if "%OS%" == "Windows_NT" (  
  set "DIRNAME=%~dp0%"  
) else (  
  set DIRNAME=.\  
)  
  
pushd %DIRNAME%..  
set "RESOLVED_JBOSS_HOME=%CD%"  
popd  
  
if "x%JBOSS_HOME%" == "x" (  
  set "JBOSS_HOME=%RESOLVED_JBOSS_HOME%"  
)  
  
pushd "%JBOSS_HOME%"  
set "SANITIZED_JBOSS_HOME=%CD%"  
popd  
  
if "%RESOLVED_JBOSS_HOME%" NEQ "%SANITIZED_JBOSS_HOME%" (  
    echo WARNING JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.  
)  
  
set DIRNAME=  
  
if "%OS%" == "Windows_NT" (  
  set "PROGNAME=%~nx0%"  
) else (  
  set "PROGNAME=jdr.bat"  
)  
  
rem Setup JBoss specific properties  
if "x%JAVA_HOME%" == "x" (  
  echo JAVA_HOME is not set. Unable to locate the jars needed to run jconsole.  
  goto END  
)  
  
rem Find jboss-modules.jar, or we can't continue  
if exist "%JBOSS_HOME%\jboss-modules.jar" (  
    set "RUNJAR=%JBOSS_HOME%\jboss-modules.jar"  
) else (  
  echo Could not locate "%JBOSS_HOME%\jboss-modules.jar".  
  echo Please check that you are in the bin directory when running this script.  
  goto END  
)  
  
rem Setup The Classpath  
set CLASSPATH=%JBOSS_HOME%\bin\client\jboss-cli-client.jar  
  
  
"%JAVA_HOME%\bin\jvisualvm.exe" "-cp:a" "%CLASSPATH%"  
  
:END  
goto :EOF  
:EOF 

Now inside jvisualvm you can connect to JBoss EAP 6 using JMX and a URL of the form service:jmx:remoting-jmx://<host>:<native-management-port>

See also "How to connect to JBoss EAP 6 using JConsole" (https://access.redhat.com/solutions/149973)

Thursday, April 9, 2015

Creating a JMS Bridge with XA on JBoss EAP 6.3

In case you want to create a JMS Bridge supporting XA on JBoss EAP 6.3 here are some hints on how to achieve this. I'm using HornetQ and ActiveMQ (with resource-adapter version 5.11.1) througout the example with queue A and C residing on ActiveMQ and a queue B on HornetQ, messages will be bridged from queue A to B to C.

In standalone configuration file add the following admin-object to the resource-adapter configuration for ActiveMQ:
<admin-object class-name="org.apache.activemq.ActiveMQXAConnectionFactory" jndi-name="java:/AMQXAConnectionFactory" enabled="true" use-java-context="true" pool-name="AMQXAConnectionFactory">
     <config-property name="brokerURL">
                                failover:(tcp://localhost:61616)?jms.rmIdFromConnectionId=true&amp;maxReconnectAttempts=0&amp;jms.xaAckMode=2&amp;jms.userName=admin&amp;jms.password=redhat
      </config-property>
 </admin-object>
You also need to do a modification to the ra.xml of the ActiveMQ resource-adapter consisting of adding the following:

<adminobject>
          <adminobject-interface>javax.jms.XAConnectionFactory</adminobject-interface>
          <adminobject-class>org.apache.activemq.ActiveMQXAConnectionFactory</adminobject-class>
          <config-property>
            <config-property-name>brokerURL</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
          </config-property>
</adminobject>

In the messaging subsystem add the following after hornetq-server:

<jms-bridge name="activemq-hornetq">
     <source>
           <connection-factory name="AMQXAConnectionFactory"/>
           <destination name="queue/queueA"/>
      </source>
      <target>
            <connection-factory name="XAConnectionFactory"/>
            <destination name="queue/queueB"/>
       </target>
       <quality-of-service>ONCE_AND_ONLY_ONCE</quality-of-service>
       <failure-retry-interval>1000</failure-retry-interval>
       <max-retries>-1</max-retries>
       <max-batch-size>1</max-batch-size>
       <max-batch-time>100</max-batch-time>
</jms-bridge>
<jms-bridge name="hornetq-activemq">
       <source>
             <connection-factory name="XAConnectionFactory"/>
             <destination name="queue/queueB"/>
       </source>
       <target>
             <connection-factory name="AMQXAConnectionFactory"/>
             <destination name="queue/queueC"/>
       </target>
       <quality-of-service>ONCE_AND_ONLY_ONCE</quality-of-service>
       <failure-retry-interval>1000</failure-retry-interval>
       <max-retries>-1</max-retries>
       <max-batch-size>1</max-batch-size><max-batch-time>100</max-batch-time>
 </jms-bridge>

Now your JMS bridge is ready to operate!