|
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.
The Central Server establishes a primary session with the JMS server and a listener is registered.
The DMS posts a message in this primary session during the DMS startup.
On receiving the message, the central server initializes a read/write session as per the configurations in the configuration file jms_config.conf.
After the message is posted, the DMS initializes a read/write session similar to central server

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
During its startup, a primary session is created by the Central Server in the JMS. This session is not used after that. The queue name is configured in the Central Server as CENTRAL1.
The DMS containing the same PRIMARY_QUEUE ID as that of the Central Server, does a RMI lookup for the queue name.
A read/write queue is established between the DMS<>JMS<>Central Server to post messages in the appropriate queue. The Write queue of the DMS is the Read queue of the Central Server and vice versa.
FE and DMS
During its startup, a primary queue is created by the FE Server in the JMS. This session is not used further. The DMS containing the same PRIMARY_QUEUE ID as that of the FE Server posts a message in the Write queue that it creates.
The FE server reads
the message from this queue and then posts its message by establishing
it's write queue in the JMS.
As mentioned above, the Write queue of the DMS is the Read queue of
the FE Server and vice versa.
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:
USERNAME: Provide the name of the admin user of the JMS Server.
PASSWORD: Provide the password for the admin user of the JMS Server.
PROVIDER URL: Provide the url of the TCP/RMI port of the machine where the JMS Server is running.
INITIAL_CONTEXT_FACTORY:com.sun.enterprise.naming.SerialInitContextFactory
QUEUE CONNECTION FACTORY: QueueConnectionFactory
PRIMARY QUEUE NAME: <RegionID>:Queue Name
Implementation Details for JMS Communication
DMS Implementations
DMSJMSClient
Central Server Implementations
CentralJMSClient
AdminJMSClient
AdminClientIfc
OpenJMSAdminClientImpl
QueueHandler
Common Implementations
JMSConfig
JMSRegionalCommImpl
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
CentralJMSClient:
This implementation is present in the Central Server and is responsible
for creating a primary session with the JMS. This class implements SPPCommInitIfc.
The init() method takes Properties
as parameters. The user name, password, Provider URL, AdminJMSClient instance,
and a new instance of QueueHandler are retrieved.
The open() method of SppCommInitIfc
creates and returns an instance of SPPRegionalCommIfc. The DMS ID (RegionID)
is associated to this instance.
|
... comm_impl = new JMSRegionalCommImpl(); comm_impl.setRegionID(region); ... return comm_impl; ... |
The JMSConfig
class is a common implementation that loads the configuration file jms_config.conf present in <Web NMS
Home>/conf
directory and loads the configuration information. Appropriate error messages
are displayed if any of the configuration information is not provided
properly. This class checks for proper administrator privilege.
The Read Queues and Write Queues are created between the DMS<-->JMS<-->Central
Server, with the Queues bearing unique IDs. Since the Read/Write Queues
can be added at runtime, the load()
method is used to load at every call.
The
JMSRegionalCommImpl is a common implementation. This class implements
SPPRegionalCommIfc interface and is responsible for establishing communication
with the JMS Server. The initialize(), write(), read(), and shutdown() methods are
used.
In the initialize() method, the DMS and the Central Server look
up a queue from JNDI to send and receive messages. A queue session is
established as follows:
|
... 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.
The QueueHandler
implementation is present in the Central Server. This class implements
javax.jms.MessageListener. The
methods of this class are init() and onMessage(). This class listens for
the messages from DMS during its startup.
When there are some Distributed Mediation Servers already registered
with the Central Server, and when the Central server is restarted (a warm
start), the communication is initialized for all the registered DMS in
the init() method.
|
... primary = JMSConfig.getInstance().getPrimaryQueueName(); Properties context_props = new Properties(); context_props.put(Context.INITIAL_CONTEXT_FACTORY, JMSConfig.getInstance().getINITIAL_CONTEXT_FACTORY()); ... ... |
The onMessage()
method is notified when a message with the registered ID is received in
the JMS.
|
... ObjectMessage object_message = (ObjectMessage) message; DataObject object = (DataObject)object_message.getObject(); String region = object.getRegionID(); ... ... |
AdminClientIfc
- This is an interface present in the Central Server. It contains methods
to perform administration tasks on JMS server such as adding/removing
a Queue, checking if the Queue is valid, getting the Queue name, etc.
AdminJMSClient-
This implementation is present in the Central Server and is responsible
for interacting with AdminClientIfc implementation.
OpenJMSAdminClientImpl - This class Implements AdminClientIfc for communication using OpenJMS. You must write your own implementation for any other JMS such as JBoss.
What needs to be done for OpenJMS and JBoss Communication
OpenJMS Communication: For communication using OpenJMS,
Apply the JMS add-on
Make
the configurations in the jms_config.conf file as explained above.
JBoss Communication: For communication using JBoss,
Apply the JMS add-on
Write your class that implements AdminClientIfc (default implementation provided for OpenJMS)
Configure the name of this class in the configuration file jms_config.conf in addition to the other details mentioned in the configuration file.
|