Contents


Integrating WebSphere Message Broker with Apache ActiveMQ

Comments

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
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
    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
    Figure 3
  4. Click on the Queues tab and create two queues: IN.Q and OUT.Q:
    Figure 4
    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
    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
    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
    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
    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
    Figure 9
  2. Put a sample HL7 message on IN.Q:
    Figure 10
    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.


Downloadable resources


Related topics


Comments

Sign in or register to add and subscribe to comments.

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