Version 7

    ActiveMQ - JBoss Integration

     

    -


    JBossAS Installation

     

    First, you have to install JBossAS , replace the default HypersonicDatabase Engine with a production ready database server .

     

     

     

    ActiveMQ Preparation

     

    Download the latest stable version from http://activemq.apache.org/download.html. We have tested with ActiveMQ 4.0.x series and recommend you the same. If you're using ActiveMQ 4.0.x, you need to download the stable spring binaries from 1.2x branch (http://www.springframework.org/download).

     

     

    Unzip the ActiveMQ binary distribution and configure the activemq resource adapter

     

    $ tar xzvf apache-activemq-4.1.1.tar.gz
    $ cd apache-activemq-4.1.1/lib/optional/
    $ mkdir activemq-ra.rar 
    -copy the activemq-rar-4.1.1.rar to the newly created directory
    $ cp activemq-rar-4.1.1.rar activemq-ra.rar/ 
    $ cd activemq-ra.rar/ 
    $ jar xvf activemq-rar-4.1.1.rar 
    $ rm activemq-rar-4.1.1.rar 
    $ rm spring-2.0.jar ( Please refer the Note ) 
    

     

     

    Configure the broker

     

    Copy downloaded spring library off the 1.2.x branch , here, in place of the the deleted library

     

    Note: You don't have to download and integrate spring libraries from Spring, if you're using ActiveMQ-5.1.0 or above. You have to do this on ActiveMQ-4.x for there's a known issue

     

     

     

    $ vi META-INF/ra.xml

    Edit the ra.xml file, which is located at : META-INF/ra.xml

     

    By default, the activemq-ra is configured to use the TCP based transportation. However, since this is going to be embeded to the JBossAS, there's no real need to utilise on the TCP based transportation and to bear it's overheads, you can get rid of this by utilising on the JVM layer. To enable JVM based transportation, you have to uncomment the JVM layer transportation and comment the TCP layer transportation as follows :

     

     

     

    <config-property>
    .....
    .....
    <!--<config-property-value>tcp://localhost:61616</config-property-value> -->
        <config-property-value>vm://localhost</config-property-value>
    </config-property>
    

     

     

     

     

    Next step is to configure the activemq configuration file, broker-config.xml.

     

    $ vi broker-config.xml

     

    Configure the datadirectory, you can also specify the default detasource configuration for that.

     

     

     

    <persistenceAdapter>
          <journaledJDBC journalLogFiles="5" dataDirectory="../data"></journaledJDBC>
          <!-- To use a different datasource, use th following syntax : -->
          <!--
          <journaledJDBC journalLogFiles="5" dataDirectory="../data" dataSource="#DefaultDS"></journaledJDBC>\\
            -->
    </persistenceAdapter>
    

     

     

     

     

    Configure the broker name

     

       

    <broker useJmx="true" brokerName="jboss-activemq-broker">
    

    Apply the newly defined brokername on the transport connector

     

    <transportConnectors>
           <!-- prefixing a connector with discovery: causes the connector to be advertiesed over rendezvous -->
           <transportConnector brokerName="jboss-activemq-broker" uri="tcp://localhost:61616" discoveryUri="multicast://default"></transportConnector>
    </transportConnectors>
    

     

     

     

     

    Once this is done, you have to enable the jbossmq-ra to read this configuration file. to do this :

     

    $ vi META-INF/ra.xml

     

    Uncomment the following, this will make sure that the broker-config.xml is used for the configuration :

     

      <config-property>
        <!--
           <config-property-value>xbean:broker-config.xml</config-property-value>
         -->
      </config-property>
    

     

     

    -


    The final step is to configure and deploy the connection factories via JCA. In this example, this is named as activemq-jms-ds.xml

     

     

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE connection-factories PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN" "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
    <connection-factories>
        <tx-connection-factory>
           <jndi-name>activemq/QueueConnectionFactory</jndi-name>
           <xa-transaction></xa-transaction>
           <track-connection-by-tx></track-connection-by-tx>
           <rar-name>activemq-ra.rar</rar-name>
           <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
           <ServerUrl>vm://10.65.6.155</ServerUrl>
           <!--
           <UserName>sa</UserName>
           <Password></Password>
           -->
           <min-pool-size>20</min-pool-size>
           <max-pool-size>100</max-pool-size>
           <blocking-timeout-millis>30000</blocking-timeout-millis>
           <idle-timeout-minutes>3</idle-timeout-minutes>
        </tx-connection-factory>
        <tx-connection-factory>
           <jndi-name>activemq/TopicConnectionFactory</jndi-name>
           <xa-transaction></xa-transaction>
          <track-connection-by-tx></track-connection-by-tx>
          <rar-name>activemq-ra.rar</rar-name>
          <connection-definition>javax.jms.TopicConnectionFactory</connection-definition>
          <ServerUrl>vm://10.65.6.155</ServerUrl>
          <!--
          <UserName>jbossuser</UserName>
          <Password></Password>
          -->
          <min-pool-size>20</min-pool-size>
          <max-pool-size>100</max-pool-size>
          <blocking-timeout-millis>30000</blocking-timeout-millis>
          <idle-timeout-minutes>3</idle-timeout-minutes>
       </tx-connection-factory>
       <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.queue:name=outboundQueue">
          <attribute name="JNDIName">activemq/queue/outbound</attribute>
          <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
          <attribute name="Type">javax.jms.Queue</attribute>
          <attribute name="Properties">PhysicalName=queue.outbound</attribute>
       </mbean>
       <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.topic:name=inboundTopic">
          <attribute name="JNDIName">activemq/topic/inbound</attribute>
          <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-ra.rar'</depends>
          <attribute name="Type">javax.jms.Topic</attribute>
          <attribute name="Properties">PhysicalName=topic.inbound</attribute>
       </mbean>
    </connection-factories>
    

     

     

    Once you have completed the give steps, you can successfully execute the examples, which are shipped with the ActiveMQ distribution.