You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 12 Next »


Article donated by: Krishnakumar Balachandar (mailto:), Hernan Cunico

Apache Geronimo is bundled with an open source messaging provider called ActiveMQ. A J2EE application deployed on Geronimo can use Queue's and Topics created in ActiveMQ and a Message Driven Bean ( MDB ) can act as an endpoint to pick messages from a Queue or Topic. This article discusses how to use any other third party messaging product that supports JMS specification with Geronimo. The example used in this article uses IBM Websphere MQ ( WMQ ) as the messaging provider and a Resource Adapter ( RA ) is used to integrate MQ with Geronimo. The RA provides outbound communication to Queues and Topics. Inbound communication of RA picks message from a Queue and sends to MDB deployed in Geronimo.

Integrating IBM Websphere MQ in Apache Geronimo

The following list and figure illustrates the different components of Apache Geronimo and IBM Websphere MQ.

  • WebSphere MQ Messaging Provider
  • MQ RA resource adapter
  • JNDI Bindings for MQ
  • Message Driven Bean for Inbound Communication
  • Servlet for Outbound Communication

WMQ contains Queue and Topic objects and Connection Factory is created in JNDI registry. A JCA RA is deployed in Geronimo that provides outbound and inbound communication to WMQ. Outbound communication from RA looks up connection factory from JNDI to create connections to Destination. For inbound communication MDB acts as an endpoint and RA polls MQ to pick messages and send to MDB.

Back to Top

MQ Resource Adapter

JCA RA deployed in Geronimo provides integration with MQ. The following example shows sections of the RA plan (ra.xml) and config properties.

Excerpt from the RA plan (ra.xml)
<outbound-resourceadapter>
   <config-property>
   <description>jndi provider</description>
   <config-property-name>url</config-property-name>
   <config-property-type>java.lang.String</config-property-type>
  </config-property>
  <config-property>
   <description>icf</description>
   <config-property-name>icf</config-property-name>
   <config-property-type>java.lang.String</config-property-type>
  </config-property>
  <config-property>
   <description>name</description>
   <config-property-name>name</config-property-name>
   <config-property-type>java.lang.String</config-property-type>
  </config-property>
<outbound-resourceadapter>
<inbound-resourceadapter>
 <activationspec>
  <required-config-property>
   <config-property-name>url</config-property-name>
  </required-config-property>
  <required-config-property>
   <config-property-name>icf</config-property-name>
  </required-config-property>
  <required-config-property>
   <config-property-name>name</config-property-name>
  </required-config-property>
  <required-config-property>
   <config-property-name>destination</config-property-name>
  </required-config-property>
</activationspec>
</inbound-resourceadapter>
<adminobject>
  <config-property>
  <config-property-name>PhysicalName</config-property-name> 
  <config-property-type>java.lang.String</config-property-type> 
  </config-property>
</adminobject>
<adminobject>
  <config-property>
   <config-property-name>PhysicalName</config-property-name>
   <config-property-type>java.lang.String</config-property-type> 
  </config-property>
</adminobject>

The RA has the following configuration properties:

  1. Outbound
    url - JNDI provider url (for example ldap://test/o=test,c=com, file: /C:/JNDI-Directory).
    icf - Initial Context Factory (for example com.sun.jndi.fscontext.RefFSContextFactory).
    name - Factory Name (for example ivtQCF).
  1. Inbound
    url - JNDI provider url.
    icf - Initial Context Factory.
    name - Factory Name.
    destination - Destination to pick messages form (for example Queue Name).
  1. Administered Objects
    Physical Name - name of queue or topic created in JNDI of Geronimo.

The properties of RA are mapped to Geronimo specific RA plan (geronimo-mq.xml) which contains instance specific properties for outbound connections and administered objects.

Excerpt from the Geronimo specific RA plan (geronimo-mq.xml)
<outbound-resourceadapter>
...
 <connection-definition>
   <connectiondefinition-instance>
     <name>MQQueueFactory</name>
	<config-property-setting name="url"></config-property-setting>
	<config-property-setting name="icf"></config-property-setting>
	<config-property-setting name="name"></config-property-setting>
	<connectionmanager>
...
</connection-definition>
<adminobject>
...
<adminobject-instance>
     <message-destination-name>ivtQ</message-destination-name>
     <config-property-setting name="PhysicalName">SYSTEM.DEFAULT.LOCAL.QUEUE</config-property-setting>
</adminobject-instance>
</adminobject>
 <adminobject>
    <adminobject-instance>
       <message-destination-name>ivtT</message-destination-name>
        <config-property-setting name="PhysicalName">SampleTopic</config-property-setting>
 </adminobject-instance>
</adminobject>

Back to Top

Configuring MQ for Geronimo

In order to have MQ configured and running in Geronimo you will have to perform configuration tasks on both ends, that is (for this particular case) on IBM WebSphere MQ and Apache Geronimo.

Prerequisites

For this configuration example a minimum of IBM WebSphere MQ 6.0 and Apache Geronimo M5 (or later) are required to configure messaging.

Configure WebSphere MQ

  1. Create a QueueManager (MQJMS) in WMQ for Queues. A default local Queue called SYSTEM.DEFAULT.LOCAL.QUEUE is created.
  2. Create and start a Listener that listens on port 1414.
  3. Create and start a Server Connection Channel CHANNEL1.
  4. Create a QueueManager (pubsub.qmgr) in WMQ for Topics and start it as broker from services.
  5. Create and start a Listener on port 1434 for this QueueManager.
  6. Create and start a Server Connection Channel CHANNEL1.
  7. Run the MQSC command using the following file found in <MQ_home>/java/bin/MQJMS_PSQ.mqsc
    runmqsc pubsub.qmgr < MQJMS_PSQ.mqsc
  8. Create JNDI bindings for QueueConnectionFactory and TopicConnectionFactory using JMSAdmin tool.
  • Set the JMSAdmin.config to use File Context JNDI and point to C:/JNDI-Directory
  • Run the JMSAdmin tool and create the following bindings.
    QueueConnectionfactory
    DEFINE QCF(ivtQCF) HOST(localhost) PORT(1414) CHANNEL(CHANNEL1) QMGR(MQJMS) TRAN(client)
    
    TopicConnectionFactory
    def ctx(pubsub)                                                             
    chg ctx(pubsub)                                                            
    def TCF(ma0cTCF) HOST(localhost) PORT(1434) CHANNEL(CHANNEL1)qmgr(pubsub.qmgr) TRAN(client) 
    
    def t(ma0cTopic) topic(SampleTopic) for Subscriber

Back to Top

Configure Geronimo

  • No labels