|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.pricingnexus.tools.JmsWrapper
This object is the result of some frustrating weeks of work with JMS ,-)) Ok, joking off... Although JMS is probably straight forward it's sometims a little ugly to use. I.e. you have a hierachy of elements that start from Destination and goes down to the individual message. But e.g. for creating a message producer or consumer (low hierachy object which can be used for individual threads) you need a reference to the applying destination object. You even need the destination to create a message! Therefore you need to pass a lot of information from a master to a client thread, code can get really ugly. An alternative approach is to use a thread-safe wrapper than contains all necessary information and to pass just this object. It's considered to be lightweigt as it just encapsulates all neccessary JMS calls and stores refrences. As this object is not a general purpose wrapper to JMS but specifically designed for the use in Pricing-Nexus you'll also note that a lot of very specific JMS features are missing. E.g. it supports currently only text messages and no other types. $Header$
Field Summary | |
static java.lang.String |
QCF_NAME
Provider specific name for a JMS "QueueConnectionFactory". |
static java.lang.String |
TCF_NAME
Provider specific name for a JMS "TopicConnectionFactory". |
Constructor Summary | |
JmsWrapper(java.lang.String icfClassName,
java.lang.String providerURL,
int retries)
Standard constructor of class. |
Method Summary | |
void |
close()
Closes a connection. |
void |
connect(java.lang.String destinationName)
Creates JMS on the named queue or topic connection. |
javax.jms.QueueReceiver |
createQueueReceiver(int sessionID)
Creates a QueueSender for given session identifier and returns a reference to it. |
javax.jms.QueueSender |
createQueueSender(int sessionID)
Creates a QueueSender for given session identifier and returns a reference to it. |
org.pricingnexus.tools.Session |
createSession(int sessionID,
boolean transacted)
A new session is created and returned. |
javax.jms.TextMessage |
createTextMessage(int sessionID)
Creates a TextMessage and returns a reference to it. |
org.pricingnexus.tools.TopicPublisher |
createTopicPublisher(int sessionID)
Creates a TopicPublisher for given session identifier and returns a reference to it. |
org.pricingnexus.tools.TopicSubscriber |
createTopicSubscriber(int sessionID)
Creates a TopicSubscriber for given session identifier and returns a reference to it. |
org.pricingnexus.tools.QueueSession |
getQueueSession(int sessionID)
Returns a reference to a previously created QueueSession. |
org.pricingnexus.tools.Session |
getSession(int sessionID)
Returns a reference to a previously created JMS-session. |
org.pricingnexus.tools.TopicSession |
getTopicSession(int sessionID)
Returns a reference to a previously created TopicSession. |
boolean |
setIsQueue()
Corresponding to setIsTopic this method declares the obejct to be used in a queue context. |
boolean |
setIsTopic()
As our object does support Topics as well as Queues the calling context first needs to decice if an instance of this object needs to handle Topics or Queues. |
void |
startConnection()
Very simple: Starts the "stored" connection |
void |
stopConnection()
Stops the "stored" connection |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.lang.String QCF_NAME
public static java.lang.String TCF_NAME
Constructor Detail |
public JmsWrapper(java.lang.String icfClassName, java.lang.String providerURL, int retries)
icfClassName
- name of the initial context factory class (ini-Name "JMS_ICF_CLASS")
providerURL provider URL to connect to (ini-Name "JMS_URL")
numRetries Number of retries for various actions if anything does not work correctlyMethod Detail |
public boolean setIsTopic()
public boolean setIsQueue()
public void connect(java.lang.String destinationName) throws javax.jms.JMSException, javax.naming.NamingException
destinationName
- Name of queue or topic to connect toJMSException,
- NamingExceptionpublic void startConnection() throws javax.jms.JMSException
javax.jms.JMSException
- public void stopConnection() throws javax.jms.JMSException
public void close() throws javax.jms.JMSException
public org.pricingnexus.tools.Session createSession(int sessionID, boolean transacted) throws javax.jms.JMSException
sessionID
- A simple number [0..n] as unique identification of a session
transacted "true" or "false"; corresponds with the transacted flag when creating a JMS sessionjavax.jms.JMSException
- public org.pricingnexus.tools.Session getSession(int sessionID)
sessionID
- number of the session to be returned; must have been created previouslypublic org.pricingnexus.tools.TopicSession getTopicSession(int sessionID)
sessionID
- number of the session to be returned; must have been created previouslypublic org.pricingnexus.tools.QueueSession getQueueSession(int sessionID)
sessionID
- number of the session to be returned; must have been created previouslypublic javax.jms.QueueSender createQueueSender(int sessionID) throws javax.jms.JMSException
sessionRef
- reference to existing session. If a session with the appropriate identifier cannot be return value
will be null.javax.jms.JMSException
- public javax.jms.QueueReceiver createQueueReceiver(int sessionID) throws javax.jms.JMSException
sessionRef
- reference to existing session. If a session with the appropriate identifier cannot be return value
will be null.javax.jms.JMSException
- public org.pricingnexus.tools.TopicPublisher createTopicPublisher(int sessionID) throws javax.jms.JMSException
sessionRef
- reference to existing session. If a session with the appropriate identifier cannot be return value
will be null.javax.jms.JMSException
- public org.pricingnexus.tools.TopicSubscriber createTopicSubscriber(int sessionID) throws javax.jms.JMSException
sessionRef
- reference to existing session. If a session with the appropriate identifier cannot be return value
will be null.javax.jms.JMSException
- public javax.jms.TextMessage createTextMessage(int sessionID) throws javax.jms.JMSException
sessionRef
- reference to existing session. If a session with the appropriate identifier cannot be return value
will be null.javax.jms.JMSException
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |