DevPortal

How do I configure JMS Adapters for J2EE Applications?


Table of Contents


How do I configure JMS Adapters for J2EE Applications?

Pramati J2EE Server provides the Message Server in an easy-to-use and standard way in creating a Java-based implementation using the JMS adapter. This reduces the cost of purchasing an existing messaging product and the Java interface.

The JMS adapter provides an interface to other Message Servers that implement javax.jms to access the JMS resources, making it JMS-compliant. This enables seamless plug-in of an external JMS. This involves:

The JMS provider:

JMS enables Java programs to create, send, receive, and read messages of an enterprise messaging system. A JMS application is made up of a set of application-defined messages and a set of clients that exchange them.

How do I use resource-config.xml to create JMS Resources?

You can configure a JMS resource using resource-config.xml by adding a <jms-adapter _moz-userdefined=""> tag under the <jms-adapters _moz-userdefined=""> tag. The resource-config.xml appears as below:

<?xml version="1.0" encoding="UTF-8"?>
<DOCTYPE resource-service PUBLIC '-//Pramati Technologies //DTD Pramati Resource Service//EN'
'http://www.pramati.com/dtd/pramati-resource-service.dtd'>
<resource-service>
  <resources>
    <default-resources> </default-resources>
    <datasources> </datasources>
    <connection-factories> <connection-factories>
    <mail-resources> <mail-resources>
    <url-resources> <url-resources>
    <jms-adapters>
      <jms-adapter name="default" description="nodesc" interface-class="com.pramati.jms.client.JMSProviderImpl">
        <properties>
          <property name="java.naming.factory.initial" value="com.pramati.naming.client.PramatiClientContextFactory"/>
          <property name="java.naming.provider.url" value="rmi://127.0.0.1:9191"/>
        </properties>
        <jms-resource bind-name="resJMSTopic" type="javax.jms.Topic" target-name="JMSTopic"/>
      </jms-adapter>
    </jms-adapters>
  </resources>
</resource-service>

How do I configure JMS Adapters in J2EE Servers Using XML?

JMS Adapters are setup in a J2EE Server instance determining the connectivity to a Message Server (Embedded, Standalone, or HA-Message Server). JMS Adapters can be configured in resource-config.xml file of the J2EE Server (Standalone or cluster-node).

In case of non-embedded Message Server, that is when the JMS Service is not running in the same VM as the EJBService, specify com.pramati.naming.client.PramatiClientContextFactory for java.naming.factory.initial. Also specify the IP and port of the VM where the Message Server is running in resource-config.xml. In case of HA Message Server, provide the comma separated list of URLs of HA Message Server nodes.

Sample Configuration for Local JMS Adapters

Sample configuration for the local JMS Adapter is shown below. The sample configuration is valid only for a Message Server running in embedded mode:
<jms-adapters>
  <jms-adapter name="default" description="nodesc" interface-class="com.pramati.jms.client.JMSProviderImpl">
    <properties>
	<property name="java.naming.factory.initial" value="com.pramati.naming.PramatiLocalContextFactory"/>
	<property name="java.naming.provider.url" value="rmi://localhost:9191"/>
    <properties>
  <jms-adapter>
</jms-adapters>

Sample Configuration for External JMS Adapters (non-HA)

Sample configuration for the external JMS Adapter (non-HA) is shown below. The sample configuration is valid only for a Message Server not running in embedded mode. jmshost is the host where the Standalone Message Server is running on Port 2099:
<jms-adapters>
  <jms-adapter name="default" description="nodesc" interface-class="com.pramati.jms.client.JMSProviderImpl">
    <properties>
	<property name="java.naming.factory.initial" value="com.pramati.naming.client.PramatiClientContextFactory"/>
	<property name="java.naming.provider.url" value="rmi://jmshost:2099"/>
    <properties>
  <jms-adapter>
<jms-adapters>

Sample Configuration for External JMS Adapters (HA)

Sample configuration for the external JMS Adapter (HA) is shown below. The sample configuration is valid only for an HA-Message Server cluster. jms2, jms1 are part of HA Message Server configuration.

<jms-adapters>
  <jms-adapter name="default" description="nodesc" interface-class="com.pramati.jms.client.JMSProviderImpl">
    <properties>
	<property name="java.naming.factory.initial" value="com.pramati.naming.client.PramatiClientContextFactory"/>
	<property name="java.naming.provider.url" value="rmi://jms2:9191,rmi://jms1:9191"/>
    <properties>
  <jms-adapter>
<jms-adapters>

Note: For HA Message Server node or a Standalone Message Server node, the resource-config.xml should not contain any JMS Adapters.

How do I use Resource Shell to add JMS Adapters?

To add a JMS adapter using the resource shell, on the resourceadmin:> prompt, enter resourceadmin:> add_jmsadapter

There are two ways to add a JMS adapter, using add_jmsadapter.

Interactive

To use the interactive mode, enter add_jmsadapter, and press Enter. This asks for all the required fields one after the other. No special flag is required for this mode.

Enter the following values needed for the command resourceadmin:> add_jmsadapter

resourceadmin> - jms adapter name * #myJMSAdapter
resourceadmin> - class name * #com.pramati.jms.client.JMSProviderImpl
resourceadmin> - java.naming.factory.initial [com.pramati.naming.PramatiLocalContextFactory] #com.pramati.naming.PramatiLocalContextFactory
resourceadmin> - java.naming.provider.url [rmi://localhost:2099] #rmi://localhost:9191
Adding JMS Server Adapter myJMSAdapter
Initialized JMS Server Adapter [myJMSAdapter]
Created  JMS Server Adapter myJMSAdapter
Added JMS Server Adapter [myJMSAdapter]

Note: Fields followed by * are mandatory. Press Enter for default values. Typing 'q' and pressing Enter at any point cancels the current command.

Non-Interactive

To use the non-interactive mode, enter add_jmsadapter. All the required attributes - the jmsAdapterName and the className in this case - have to be specified. All optional attributes have default values that can be modified. There are three ways in which you can specify the fields:

How do I use Resource Shell to Remove JMS Adapters?

To remove a JMS adapter using the resource shell, enter the following command: remove_jmsadapter <name>

How do I use Message Server Adapter Manager MBean to add JMS Adapters?

Once you have the Resource Service MBean, get the JMSServerAdapterManagerMBean by entering:

JMSServerAdapterManagerMBean jmsAdapter = resourceServiceMBean.getJMSServerAdapterManagerMBean();
After this, call the addJMSServerAdapter method on this MBean. The explanation of the parameters that are taken in the MBean are as follows:
public void addJMSServerAdapter(String name, String adapterClassName, Map initOptions)

How do I use the Console to configure JMS Adapters?

To configure a JMS adapter using the Console, select Configure > Resources. This displays the Resources screen. If there are JMS resources added earlier, the JMS adapters section displays the following details:

Table 1: JMS adapter details

FieldsDescription
NameThe JNDI name of the JMS adapter. This is a mandatory field and must be unique.
XA Connection FactoryThe XA datasource name, which provides connections that can participate in distributed transactions.
QueueThe number of messages sent by a valid JMS client waiting in queue.
TopicThe number of topics waiting to be processed.
PropertiesUse Edit to modify and view the existing properties for the JMS adapter.
AddUse Add to add a JMS adapter.
DeleteUse Delete to delete a JMS adapter.

How do I add JMS Adapters?

To add a JMS adapter:

  1. Click Add under the JMS Resources section
  2. Specify here the following information:

    Table 2: Details needed to add a JMS adapter

    FieldsDescription
    NameEnter here the adapter name. This is a mandatory field.
    ClassEnter here the class name of the interface and Server implementation, and is required for connecting to JMS. The default value is com.pramati.jms.client.JMSProviderImpl for Pramati JMS. This is a mandatory field.

    Note: Implementation of JMS adapter for SoniqueMQ is com.pramati.resource.JMSProvider_SonicMQ. To plug-in any other JMS, provide the implementation and enter the required adapter class name.
  3. Click Next to set the value of the implementation properties. The attributes are:

    Table 3: Implementation properties of JMS adapters

    FieldsDescription
    NameThis is the property name and is not editable.
    ValueEnter here the value of the property. The default values are already set in this field.
    DescriptionEnter here a description for the class name property.

After entering the values, click Next to reach Step 3 of adding a JMS adapter. On this page, set the JNDI names for XAConn Factory, Queue, and Topic. The JNDI name is used to bind the resource to the Server and is used to look up the destination within the JNDI namespace.

XAConn Factory, Queue, and Topic are JMS destinations to which the messages are sent and received. Provide all the above information and click Save. The JMS resource is added after the JMS starts. If the JMS is already running, the JMS resource is added immediately.

How do I edit JMS Adapters?

You cannot modify a JMS adapter after it has been created. To modify a JMS adapter, you need to delete it and recreate the resource. To edit a JMS resource for an existing adapter, click Edit against the adapter you want to modify. This displays the JMS Adapter Details screen.

You cannot edit the adapter class name and the properties field, but you can set the JNDI names for XAConn Factory, Queue, and Topic. Enter JNDI names against the respective fields, and click Save.

How do I delete JMS Adapters?

Select the JMS adapter to be deleted using the check box on the Resources page and click Delete.


Related Topics:

© Pramati Technologies 2007 Runs on Pramati Server | Feedback | Legal