12.6.1.5 JMS Communication



 

What is JMS?

 

JMS is an open source implementation of Sun Microsystems's Java Message Service API 1.0.2 Specification. This implementation provides support for TCP, HTTP, RMI, and SSL protocols, and is a reliable messaging model. The data to be transferred between the Central Server and the DMS are stored in the JMS Server in the form of Queues and Topics using JNDI.

 

 

Prerequisites

 
1. JMS Server must be available, and must be running before the Central Server startup.
2. The JMS Add-on must be applied on Web NMSRME.
 

Steps to Apply JMS Add-on

 
The JMS Add-on is available in form of a .ppm file and is compatible over Web NMS RME 4.5 with Service Pack 1 or Web NMS RME 4.7 and above. Contact nms-support@adventnet.com to obtain the Add-on.
 

How It Works?

  1. The Central Server establishes a primary session with the JMS server and a listener is registered.

  2. The DMS posts a message in this primary session during the DMS startup.

  3. On receiving the message, the central server initializes a read/write session as per the configurations in the configuration file jms_config.conf.

  4. After the message is posted, the DMS initializes a read/write session similar to central server

JMS Communication

Fig: JMS Communication in Web NMS RME

 

In the above flow diagram, communication between the Central Server and DMS through the JMS, and communication between a distributed FE component and the DMS through the JMS is represented.

To explain the workflow further,
 

Central and DMS

 

FE and DMS

 

 

 

Communication Between Central and DMS Using JMS 

 

After you apply the ppm, configure the following parameters in the configuration file jms_config.conf present in <Central/DMS Home>/conf directory:

 

Implementation Details for JMS Communication

 
 

DMS Implementations

Central Server Implementations

Common Implementations

DMS Implementations

 

The DMSJMSClient implementation is present in the Distributed Mediation Server and is responsible for creating a primary session with JMS. This class implements SPPCommInitIfc . The init() method is used to create a Queue Connection and a Queue Session with the JMS Server, and  the open() method is used to establish communication where an instance of the communication session object is created and an instance of SPPRegionalCommIfc is returned. If establishing connection is not successful, then CommunicationException is displayed.

In the init() method, an InitialContext is constructed as shown below to connect to the JMS Server:

 

...

QueueConnectionFactory connection_factory = (QueueConnectionFactory)context.lookup(JMSConfig.getInstance().getQueueConnectionFactory());

...

 

 The QueueConnectionFactory is retrieved in this class and a QueueConnection is created as follows:

 

...

QueueConnectionFactory connection_factory = (QueueConnectionFactory)context.lookup(JMSConfig.getInstance().getQueueConnectionFactory());

QueueConnection connection = connection_factory.createQueueConnection();

...

 

The QueueConnectionFactory is then used to start a queue connection as follows:

 

...

QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

connection.start();

...

 

 

The sender (DMS) and the receiver (Central Server) need to look up a queue from JNDI to send and receive the messages.

 

...

queue = (Queue)context.lookup(JMSConfig.getInstance().getPrimaryQueueName());

...

 

If the queue name is not configured properly, a message to this effect is logged.

 

The messages are posted and received from a queue. The DMS ID (RegionID) is associated with the DataObject to uniquely identify the DMS to which the message/data belongs:
 

...

sender = session.createSender(queue);

QueueReceiver receiver = session.createReceiver(queue);

...

 

 

Central Server Implementations

 

...

comm_impl =  new JMSRegionalCommImpl();

comm_impl.setRegionID(region);

...

return comm_impl;

...

 

...

session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

connection.start();

...

 

     The write() method writes the data to the JMS Session.

 

...

object_message = session.createObjectMessage();

object_message.setObject(object);

sender.send(object_message);

...

return null;

...

 

 

    The read() method reads the data from the JMS Session.

 

...

object = (DataObject)object_message.getObject();

...

return object;

...

...

 

     CommunicationException is thrown if there is any problem in writing into the JMS Session or when reading

     from it.

 

     Communication is shutdown using the shutdown() method of this class.

 

 

What needs to be done for OpenJMS and JBoss Communication

 

 

 



Copyright © 1996-2004, AdventNet Inc. All Rights Reserved.