Version 6

     

    Recently Red Hat announced that his family of middleware portfolio was extended with acquisiton of FuseSource.

    One of the FuseSource marvelous products is Fuse MQ Enterprise - an implementation of messaging broker based on Apache ActiveMQ.

     

    To reflect this development we tried how JBoss AS 7 and the new member of JBoss/Red Hat family work together.

     

    JBoss AS 7 and ActiveMQ

    Limitations

    • JBoss AS 7.1.1 contains bug that prevents proper interpoperability - so the testing will be done with JBoss AS 7.2 nightly

    Versions used

    • JBoss AS 7.2 nightly
    • Apache ActiveMQ 5.6.0

     

    We will test two different deployments

    • ActiveMQ deployed inside JBoss AS
    • ActiveMQ deployed outside JBoss AS

     

    ActiveMQ as an external messaging broker

    General overview of steps necessary to be completed

    • Install ActiveMQ resource adapter into JBoss AS
    • Configure JMS connection factories
    • Configure JMS admin objects to establish link between JMS queues/topics and ActiveMQ destinations
    • Configure JCA endpoint for MDB

     

    Step-by-step guide

    apache-activemq-5.6.0/bin/activemq
    

     

                <resource-adapters>
                    <resource-adapter>
                        <archive>
                            activemq-ra.rar
                        </archive>
                        <transaction-support>XATransaction</transaction-support>
                        <config-property name="ServerUrl">
                            tcp://localhost:61616
                        </config-property>
                        <connection-definitions>
                            <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/activemq/ConnectionFactory" enabled="true" use-java-context="true" pool-name="ActiveMQConnectionFactoryPool" use-ccm="true">
                                <xa-pool>
                                    <min-pool-size>1</min-pool-size>
                                    <max-pool-size>20</max-pool-size>
                                </xa-pool>
                            </connection-definition>
                        </connection-definitions>
                        <admin-objects>
                            <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/activemq/queue_in" enabled="true" use-java-context="true" pool-name="ActiveMQQueue.queue_in">
                                <config-property name="PhysicalName">
                                    queue.queue_in
                                </config-property>
                            </admin-object>
                            <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/activemq/queue_out" enabled="true" use-java-context="true" pool-name="ActiveMQQueue.queue_out">
                                <config-property name="PhysicalName">
                                    queue.queue_out
                                </config-property>
                            </admin-object>
                        </admin-objects>
                    </resource-adapter>
                </resource-adapters>
    

     

    • Start JBoss AS with command

     

    bin/standalone.sh -c standalone-full.xml

     

    • Deploy an MDB that contains a code similar to this sample

     

    package org.jboss.test.mdb;
    
    
    import javax.annotation.Resource;
    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.EJBException;
    import javax.ejb.MessageDriven;
    import javax.jms.Connection;
    import javax.jms.ConnectionFactory;
    import javax.jms.DeliveryMode;
    import javax.jms.Destination;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    import javax.jms.MessageProducer;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import org.jboss.ejb3.annotation.ResourceAdapter;
    
    
    @MessageDriven(activationConfig = {
          @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
          @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
          @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue.queue_in") }) // Note the physical name of the queue
    @ResourceAdapter("activemq-ra.rar")
    public class TestMessageBean implements MessageListener {
    
       @Resource(mappedName = "java:/activemq/ConnectionFactory")
       private ConnectionFactory connectionFactory;
       @Resource(mappedName = "java:/activemq/queue_out") // Note the mapped name of the queue
       private Destination queue;
       private Connection connection;
    
       public void init() throws JMSException {
          connection = connectionFactory.createConnection();
          connection.start();
       }
    
       public void destroy() throws JMSException {
          connection.close();
       }
    
    
       private void sendMessage(String text) throws JMSException {
          Session session = null;
          MessageProducer sender = null;
          try {
             session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
             sender = session.createProducer(queue);
             sender.setDeliveryMode(DeliveryMode.PERSISTENT);
    
             TextMessage response = session.createTextMessage(text);
             sender.send(response);
          } finally {
             try {
                if (sender != null) {
                   sender.close();
                }
             } finally {
                if (session != null) {
                   session.close();
                }
             }
          }
       }
    
        @Override
       public void onMessage(Message message) {
          try {
             init();
             String text = ((TextMessage) message).getText();
             sendMessage("Reply for '" + text + "'");
          } catch (JMSException e) {
             throw new EJBException("Error in JMS operation", e);
          }
          finally {
             try {
                destroy();
             } catch (JMSException e) {
                throw new EJBException("Error in closing connection", e);
             }
          }
       }
    }
    

     

    ActiveMQ as an internal messaging broker

    Installation procedure is almost the same as in case of external provider

    • Installation of ActiveMQ will be skipped
    • The ActiveMQ provider will be started inside JCA RA
    • TCP transport protocol will be replaced with in-memory communication

    Step-by-step guide

    • Download JBoss AS 7.2 nightly from https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/
    • Unpack the downloaded package
    • Download ActiveMQ resource adapter from http://repo1.maven.org/maven2/org/apache/activemq/activemq-rar/5.6.0/activemq-rar-5.6.0.rar
    • Rename the resource adapter file to activemq-ra.rar
    • Copy activemq-ra.rar to standalone/deployments directory in JBoss AS
    • Open META-INF/ra.xml in activemq-ra.rar
    • Set ServerUrl configuration property to vm://localhost
    • Make sure that BrokerXmlConfig configuration property is set to xbean:broker-config.xml
    • Open broker-config.xml in activemq-ra.ra
    • Set <kahaDB directory="..."/> to point to an existing directory (recommended is to use standalone/data/activemq directory in JBoss AS
    • Open standalone/configuration/standalone-full.xml configuration file (we need full server profile)
    • Add this snippet into the subsystem urn:jboss:domain:resource-adapters:1.0 (note the change in ServerUrl property)

     

                <resource-adapters>
                    <resource-adapter>
                        <archive>
                            activemq-ra.rar
                        </archive>
                        <transaction-support>XATransaction</transaction-support>
                        <config-property name="ServerUrl">
                            vm://transport
                        </config-property>
                        <connection-definitions>
                            <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/activemq/ConnectionFactory" enabled="true" use-java-context="true" pool-name="ActiveMQConnectionFactoryPool" use-ccm="true">
                                <xa-pool>
                                    <min-pool-size>1</min-pool-size>
                                    <max-pool-size>20</max-pool-size>
                                </xa-pool>
                            </connection-definition>
                        </connection-definitions>
                        <admin-objects>
                            <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/activemq/queue_in" enabled="true" use-java-context="true" pool-name="ActiveMQQueue.queue_in">
                                <config-property name="PhysicalName">
                                    queue.queue_in
                                </config-property>
                            </admin-object>
                            <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/activemq/queue_out" enabled="true" use-java-context="true" pool-name="ActiveMQQueue.queue_out">
                                <config-property name="PhysicalName">
                                    queue.queue_out
                                </config-property>
                            </admin-object>
                        </admin-objects>
                    </resource-adapter>
                </resource-adapters>
    
    • The rest of the steps is same as for the external broker

     

    JBoss AS 7 and Fuse MQ Enterprise

    Limitations

    • JBoss AS 7.1.1 contains bug that prevents proper interpoperability - so the testing will be done with JBoss AS 7.2 nightly
    • There is no resource adapter available fro Fuse MQ - a provisional one will be created
    • There is a bug in Fuse MQ that prevents the integration (Fuse MQ 7.0.0 is base on ActiveMQ 5.5.1)

    Versions used

    • JBoss AS 7.2 nightly
    • Fuse MQ Enterprise 7.0.0

     

    We will test two different deployments in the same way as for ActiveMQ. The steps are almost the same, so only differences are discussed later.

    Creating provisional resource adapter

    Fuse MQ as an external messaging broker

    Differences from ActiveMQ procedure

    • Follow the official Installation Guide to install and start Fuse MQ
    • Name of resource adapter activemq-ra.rar is changed into fusemq-ra.rar

     

    Fuse MQ as an internal messaging broker

    Differences from ActiveMQ procedure

    • Name of resource adapter activemq-ra.rar is changed into fusemq-ra.rar