Integrating WebSphere Message Broker with Apache ActiveMQ

This article shows you how to configure WebSphere Message Broker JMS nodes to communicate with the open-source Apache ActiveMQ messaging server as a JMS provider.

Chary Eswarachary (lingeswa@us.ibm.com), Senior Integration Architect, IBM Software Services for WebSphere, IBM

Photo of Chary EswaracharyLingachary Eswarachary is a Senior WebSphere Integration Architect at IBM Software Services for WebSphere in the US. He has 17 years of experience in the IT Industry, of which 10 years were spent working with IBM Software Group in the connectivity space. He architects, designs, and implements WebSphere solutions, and supports the end-to-end software development cycle using Smart SOA approaches. His areas of expertise include WebSphere DataPower, WebSphere Message Broker, WebSphere MQ, and WebSphere Transformation Extender. He is an IBM Redbooks author and a Certified SOA Associate, and he has several IBM product certifications. He has helped develop IBM product certification programs, and he conducts training and workshops on WebSphere and related products. You can contact Lingachary at lingeswa@us.ibm.com.



28 November 2012

Also available in Chinese

Introduction

Apache ActiveMQ (hereafter called ActiveMQ) is the most popular and powerful open-source message broker and messaging server. It supports JMS 1.1 and J2EE 1.4. Since many enterprises are integrating open-source technologies into their messaging infrastructures, this article uses a sample message to show you how to configure IBM® WebSphere® Message Broker (hereafter called Message Broker)to integrate with Apache ActiveMQ as a JMS provider.

In order to show the integration of Message Broker with ActiveMQ, this article uses the Integration-as-a-Service (IaaS) provider Meddius, which delivers an HL7 solution over JMS using ActiveMQ. In the diagram below, ActiveMQ receives HL7 messages from Meddius over JMS, and forwards them to Message Broker, which processes them using its Compute node and then writes HL7 transactions to a database table.

Figure 1
Figure 1

Configuring ActiveMQ

  1. Download and install ActiveMQ V5.7 from the Apache ActiveMQ web site to a Microsoft Windows machine where the you have the Message Broker Toolkit installed
  2. After the installation, start the ActiveMQ message broker: Run the batch file apache-activemq-5.6.0\bin\activemq.bat. Wait until you see the following message in the console output:
    Figure 2
    Figure 2
  3. Open a browser window, and then enter http://localhost:8161/admin in the URL box to open the ActiveMQ administrative console:
    Figure 3
    Figure 3
  4. Click on the Queues tab and create two queues: IN.Q and OUT.Q:
    Figure 4
    Figure 4
  5. Create a JNDI properties file with the contents shown below and save it as jndi.properties:
    java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
    java.naming.provider.url = vm://localhost
    connectionFactoryNames = 
        connectionFactory, queueConnectionFactory, topicConnectionFactory
    queue.jmsINQ = IN.Q
    queue.jmsOUTQ = OUT.Q
    Figure 5

    jmsINQ and jmsOUTQ are JMS destinations that map to the physical queues IN.Q and OUT.Q respectively.

  6. Alternatively, you can avoid creating a jndi.properties file by using a predefined connection factory called ConnectionFactory, and prefixing the actual queue names with dynamicQueues/.

Configuring WebSphere Message Broker

  1. Copy the ActiveMQ JAR file activemq-all-5.6.0.jar to the Message Broker shared classes directory.
  2. Copy the jndi.properties file created above to the Message Broker classes directory.

Configuring the message flow

  1. Launch the Message Broker Toolkit and create a message flow as shown below:
    Figure 6
    Figure 6
  2. This flow reads messages from jmsINQ, processes them, and writes HL7 transactions to a database table.
  3. Configure the JMS Input node's JMS connection parameters as shown below:
    Figure 7
    Figure 7

    Alternatively, you can define a JMSProvider configurable service and configure the node to use the configurable service. If you choose to create dynamic queues without a jndi.properties file, then configure the connection factory name as ConnectionFactory.

  4. Configure the JMS Input node's Basic tab as shown below. If you choose to create dynamic queues, then configure the source queue as dynamicQueues/IN.Q.
    Figure 8
    Figure 8
  5. Add the processing code to the Compute node, and the SQL queries to write processed transactions to a database table in the Database node.
  6. Compile the flow and create a BAR file.
  7. If the broker is running, stop it.
  8. Start the broker.
  9. Deploy the flow using the BAR file that you created.
  10. Check the broker log file to make sure that the JMS connection with ActiveMQ is established.

Testing the message flow

  1. On the ActiveMQ administrative console, click the Send tab:
    Figure 9
    Figure 9
  2. Put a sample HL7 message on IN.Q:
    Figure 10
    Figure 10
    A close-up of the test message body is shown below:
    MSH|^~\&|EPIC|EPICADT|SMS|SMSADT|199912271408|CHARRIS|ADT^A04|1817457|D|2.5|
    PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203|M||B|254 MYSTREET
     AVE^^MYTOWN^OH^44123^USA||(216)123-4567|||M|NON|400003403~1129086|
    NK1||ROE^MARIE^^^^|SPO||(216)123-4567||EC|||||||||||||||||||||||||||
    PV1||O|168 ~219~C~PMA^^^^^^^^^||||277^ALLEN MYLASTNAME^BONNIE^^^^||||||||||
    ||2688684|||||||||||||||||||||||||199912271408||||||002376853
  3. Check the database to make sure that the HL7 transactions are written to the database tables.

Conclusion

This article showed you how to configure WebSphere Message Broker JMS nodes to communicate with the open-source Apache ActiveMQ messaging server as a JMS provider. You can extend the solution described above to add a JMSOutput node to implement request-response scenarios.

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=847236
ArticleTitle=Integrating WebSphere Message Broker with Apache ActiveMQ
publish-date=11282012