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

Compare with Current View Page History

« Previous Version 23 Next »


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

Geronimo is bundled with an open source messaging provider called Active MQ. ActiveMQ supports JMS API and J2EE applications deployed in Geronimo can use the messaging capabilities of ActiveMQ by means of JMS. In the following article we shall see how to configure another third party messaging provider that supports JMS specification with Geronimo. The article includes two example scenarios using OpenJMS another open source messaging provider and IBM Websphere MQ as messaging provider.

ActiveMQ Integration with Geronimo

ActiveMQ message broker can be embedded in another product and Geronimo uses this feature to bundle ActiveMQ. Geronimo uses GBean architecture to manage the lifecycle of ActiveMQ. The properties of ActiveMQ are exposed as GBean properties and the life cycle methods start and stop are managed by the kernel.

ActiveMQ is accessed in Geronimo by means of a JCA 1.5 Resource Adapter (RA). Resource Adapter provides connection, transaction, security and work management. By means of Outbound connections of ActiveMQ RA J2EE components in Geronimo can send messages to Queue or Topic in ActiveMQ. Inbound connections of Resource Adapter provide activation of Message Beans.

Integrating JMS Provider with Geronimo

Any third party JMS provider can be integrated with Geronimo by means of a JCA 1.5 ResourceAadapter for JMS. The JMS RA wraps JMS API for creating connections to Queues or Topics and also provides Inbound Communication from a Queue or Topic.

The properties for the Resource Adapter are configured in the ra.xml. These properties are:

Outbound properties - Used to create outbound queue and topic connections

  • 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).

Inbound properties - Used to create inbound connections to MDB

  • url - JNDI provider url.
  • icf - Initial Context Factory.
  • name - Factory Name.
  • destination - Destination to pick messages form (for example Queue Name).

Administered Objects - Used to define Queue and Topic 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>JMSQueueFactory</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">queue1</config-property-setting>
</adminobject-instance>
</adminobject>
 <adminobject>
    <adminobject-instance>
       <message-destination-name>ivtT</message-destination-name>
        <config-property-setting name="PhysicalName">topic1</config-property-setting>
 </adminobject-instance>
</adminobject>

geronimo-ra.xml can be used to configure instances of resource adapters for different JMS providers. The example covered in this article shows two configurations, one for OpenJMS and one for WebsphereMQ. The connection definition properties are changed for different JMS providers. The outbound communication of Resource Adapter uses these properties to get a connection factory and create connections to Queue or Topic.

Deploying JMS Resource Adapter

This section shows how to deploy a JMS Resource Adapter and configure a J2EE application to use OpenJMS and WebSphereMQ as JMS providers. RA can be deployed in the server scope and instances can be used within scope of application.

The following steps show how to deploy the JMS Resource Adapter and configure OpenJMS and WebSphereMQ providers for Geronimo.

Configuring OpenJMS

OpenJMS starts RMI naming server on port 1019. This will conflict with the default RMI naming port in Geronimo. You will have to change the configuration for OpenJMS to use a different port and then start the OpenJMS server. Create QueueConnectionFactory and TopicConnectionFactory objects for OpenJMS. Define Queue's and Topics in openjms.xml. The following example shows relevant sections of the configuration file.

...
<Connector scheme="rmi">
      <ConnectionFactories>
        <QueueConnectionFactory name="JmsQueueConnectionFactory" />
        <TopicConnectionFactory name="JmsTopicConnectionFactory" />
        <QueueConnectionFactory name="openJMSQCF" />
        <QueueConnectionFactory name="openJMSTCF" />
      </ConnectionFactories>
    </Connector>  
...
<RmiConfiguration embeddedRegistry="true"
                      registryHost="localhost"
                      registryPort="1030"/>
...
<AdministeredDestinations>
    <AdministeredTopic name="topic1">
      <Subscriber name="sub1" />
      <Subscriber name="sub2" />
    </AdministeredTopic>
  
    <AdministeredQueue name="queue1" />
    <AdministeredQueue name="queue2" />
    <AdministeredQueue name="queue3" />
  </AdministeredDestinations>

Deploy a JMS Resource Adapter with server scope.
java -jar <geronimo_home>\bin\server.jar gerjms.rar

Deploy an enterprise application that uses OpenJMS.
java -jar <geronimo_home>\bin\server.jar <plan_home>\geronimo-application-openjms.xml gerjms.ear

The following example shows sections of Geronimo application plan for using OpenJMS. The properties for Outbound and Inbound communication are specified in the Message Bean and the Connector.

<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application" 
configId="jms.ear"  parented="jms.rar">

<module>
    <web>GERJMSWAR.war</web>
    ...
</web-app>
</module>
<module>
     <ejb>GERJMSEJB.jar</ejb>
     ...
      <message-driven>
      <ejb-name>JMSMDB</ejb-name>
      <resource-adapter>
    	<resource-link>JMSRA_1</resource-link>
      </resource-adapter>
     <activation-config>
	<activation-config-property>
	<activation-config-property-name>url</activation-config-property-name>
	<activation-config-property-value>
		  tcp://localhost:3035		</activation-config-property-value>
	</activation-config-property>
	<activation-config-property>
	<activation-config-property-name>icf</activation-config-property-name>
	<activation-config-property-value>
		  org.exolab.jms.jndi.InitialContextFactory
	</activation-config-property-value>
	</activation-config-property>
	<activation-config-property>
	<activation-config-property-name>name</activation-config-property-name>
	<activation-config-property-value>
		  openJMSQCF
	</activation-config-property-value>
	</activation-config-property>
	<activation-config-property>
	<activation-config-property-name>
                destination
         </activation-config-property-name>
	<activation-config-property-value>
		  queue1
	</activation-config-property-value>
	</activation-config-property>
    </activation-config>
    </message-driven>
    </enterprise-beans>
</openejb-jar>
</module>
<ext-module>
<connector>JMSRA_1</connector>
	<external-path>jms/gerjms/1.0/rar </external-path>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector" configId="jms.rar.1" 
``parentId="jms.ear">

<resourceadapter>
...
    <outbound-resourceadapter>
       <connection-definition>
         <connectionfactory-interface>
            org.apache.geronimo.jms.connector.JMSQueueConnectionFactory
         </connectionfactory-interface>
           <connectiondefinition-instance>
             <name>JMSQueueFactory</name>
             <config-property-setting name="url">
                   tcp://localhost:3035
             </config-property-setting>
             <config-property-setting name="icf">
                   org.exolab.jms.jndi.InitialContextFactory
             </config-property-setting>
             <config-property-setting name="name">
                   openJMSTCF
             </config-property-setting>
             <connectionmanager>
             <no-transaction />
             <no-pool />
             </connectionmanager>
        </connectiondefinition-instance>
        </connection-definition>
       <connection-definition>
 ...
        </connection-definition>
</outbound-resourceadapter>
</resourceadapter>
<adminobject>
     <adminobject-interface>javax.jms.Queue</adminobject-interface>
     <adminobject-class>
        org.apache.geronimo.jms.connector.JMSQueueImpl
     </adminobject-class>
     <adminobject-instance>
          <message-destination-name>*ivtQ*</message-destination-name>
          <config-property-setting name="PhysicalName">
          queue1
          </config-property-setting>
      </adminobject-instance>
      </adminobject>
<adminobject>
...
</adminobject>
</connector>
<ext-module>
</application>
  • No labels