org.bss.esb.util
Class JmsUtil

java.lang.Object
  extended byorg.bss.esb.util.JmsUtil

public class JmsUtil
extends java.lang.Object

Utility class for performing common JMS operations. This class provides methods for:

 1. Creating a JMS connection (Queue/Topic) given a queue connection 
 factory's JNDI name
 
 2. Get a JMS message's properties.
 
 3. Set the entries found in a given Map as JMS message's properties after
 detecting the type of each value in the supplied Map.
 
 4. Make a JMS message properties-writable, without losing the original 
 properties set on the JMS message.
 
 

Version:
1.0
Author:
Balwinder Sodhi

Constructor Summary
JmsUtil()
           
 
Method Summary
static java.util.HashMap getMessageProperties(javax.jms.Message msg)
          Returns all the properties that are set a given JMS messages, as HashMap.
static javax.jms.QueueConnection getQueueConnection(java.lang.String qcfName, boolean started)
          Returns a JMS QueueConnection object created after looking up the given queue connection factory.
static javax.jms.TopicConnection getTopicConnection(java.lang.String tcfName, boolean started)
          Returns a JMS TopicConnection object created after looking up the given topic connection factory.
static void makeMessagePropertiesWritable(javax.jms.Message msg)
          Makes the JMS message properties-writable without losing the originally set properties on this JMS message.
static void setMessageProperties(java.util.HashMap props, javax.jms.Message msg)
          Sets the entries found in props as the properties of msg.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JmsUtil

public JmsUtil()
Method Detail

makeMessagePropertiesWritable

public static void makeMessagePropertiesWritable(javax.jms.Message msg)
                                          throws javax.jms.JMSException
Makes the JMS message properties-writable without losing the originally set properties on this JMS message.

Parameters:
msg - The JMS message to be made properties-writable
Throws:
javax.jms.JMSException

getMessageProperties

public static java.util.HashMap getMessageProperties(javax.jms.Message msg)
                                              throws javax.jms.JMSException
Returns all the properties that are set a given JMS messages, as HashMap.

Parameters:
msg - The JMS message whose properties are to be obtained.
Returns:
HashMap Contains the message's properties
Throws:
javax.jms.JMSException

setMessageProperties

public static void setMessageProperties(java.util.HashMap props,
                                        javax.jms.Message msg)
                                 throws javax.jms.JMSException
Sets the entries found in props as the properties of msg. Depending on the type of the value found in props entries, appropriate setter is called on the JMS message. For example if the props has the key-value pairs as:
 {"MyIntProperty", java.lang.Integer(2234)},
 {"MyFloatProperty", java.lang.Float(44.99)}
 
 then these will be added to msg as:
 msg.setIntProperty("MyIntProperty", java.lang.Integer(2234).intValue());
 msg.setFloatProperty("MyFloatProperty", java.lang.Float(44.99).floatValue());
 
 

Parameters:
props - The HashMap containing the properties to be set.
msg - The JMS message on which the properties are to be set.
Throws:
javax.jms.JMSException

getQueueConnection

public static javax.jms.QueueConnection getQueueConnection(java.lang.String qcfName,
                                                           boolean started)
                                                    throws javax.naming.NamingException,
                                                           javax.jms.JMSException
Returns a JMS QueueConnection object created after looking up the given queue connection factory.

Parameters:
qcfName - JNDI name of the queue connection factory that will be used for creating the queue connection.
started - If set to true then the new connection is returned after caling start() on it.
Returns:
QueueConnection
Throws:
javax.naming.NamingException
javax.jms.JMSException

getTopicConnection

public static javax.jms.TopicConnection getTopicConnection(java.lang.String tcfName,
                                                           boolean started)
                                                    throws javax.naming.NamingException,
                                                           javax.jms.JMSException
Returns a JMS TopicConnection object created after looking up the given topic connection factory.

Parameters:
tcfName - JNDI name of the topic connection factory that will be used for creating the topic connection.
started - If set to true then the new connection is returned after caling start() on it.
Returns:
TopicConnection
Throws:
javax.naming.NamingException
javax.jms.JMSException


Copyright © 2005 Balwinder Sodhi. All Rights Reserved.