|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.util.jms.JmsUtil
Various low-level convenience methods for interacting with JMS queues and topics.
The class is a thin wrapper around the JMS API. The order in which you can use the methods here is rather strict. The methods are all public static so that they can be easily called via the IdM <invoke> script tag.
Below is a pseudo-code sample of how you might use JmsUtil to send a single message to a queue.
JmsWriter
.
Method Summary | |
static void |
closeConnection(javax.jms.Connection connection)
Inform the system that no more messaging will occur on the Connection. |
static void |
commitSession(javax.jms.Session session)
Commit all messaging done in the specified Session, and release any locks currently held. |
static javax.jms.BytesMessage |
createBytesMessage(javax.jms.Session session)
|
static javax.jms.MapMessage |
createMapMessage(javax.jms.Session session)
|
static javax.jms.ObjectMessage |
createObjectMessage(javax.jms.Session session)
|
static javax.jms.Queue |
createQueue(javax.naming.Context context,
java.lang.String destinationName)
Create a new Queue |
static javax.jms.QueueConnection |
createQueueConnection(javax.naming.Context context,
java.lang.String factoryName,
java.lang.String userName,
java.lang.Object password)
Create a new QueueConnection from the specified queue connection factory |
static javax.jms.QueueSender |
createQueueSender(javax.jms.QueueSession queueSession,
javax.jms.Queue queue)
Create a QueueSender to send messages to the specified queue. |
static javax.jms.QueueSession |
createQueueSession(javax.jms.QueueConnection queueConnection,
java.lang.String reliabilityMode)
Create a new QueueSession from the given QueueConnection |
static javax.jms.StreamMessage |
createStreamMessage(javax.jms.Session session)
|
static javax.jms.TextMessage |
createTextMessage(javax.jms.Session session)
|
static javax.jms.TextMessage |
createTextMessage(javax.jms.Session session,
java.lang.String text)
|
static javax.jms.Topic |
createTopic(javax.naming.Context context,
java.lang.String destinationName)
Create a new Topic |
static javax.jms.TopicConnection |
createTopicConnection(javax.naming.Context context,
java.lang.String factoryName,
java.lang.String userName,
java.lang.Object password)
Create a new TopicConnection from the specified topic connection factory |
static javax.jms.TopicPublisher |
createTopicPublisher(javax.jms.TopicSession topicSession,
javax.jms.Topic topic)
Create a Publisher for the specified topic. |
static javax.jms.TopicSession |
createTopicSession(javax.jms.TopicConnection topicConnection,
java.lang.String reliabilityMode)
Create a new TopicSession from the given TopicConnection |
static javax.naming.Context |
getInitialContext(java.util.List jndiPropertiesList)
Uses the JNDI naming service properties to get an initial context for JNDI lookups. |
static javax.naming.Context |
getInitialContext(java.util.Map jndiPropertiesMap)
Uses the JNDI naming service properties to get an initial context for JNDI lookups. |
static java.lang.String |
getMessageDetails(javax.jms.Connection conn,
javax.jms.Message msg)
Generate a String with detailed info about the Message. |
static void |
populateMapMessage(javax.jms.MapMessage message,
java.util.Map srcMap)
Populate a MapMessage with a given Map |
static void |
publish(javax.jms.TopicPublisher topicPublisher,
javax.jms.Message message,
java.util.Map deliveryOptionsMap)
Publish a message to a topic. |
static void |
rollbackSession(javax.jms.Session session)
Rollback all messaging done in the specified Session, and release any locks currently held. |
static void |
send(javax.jms.QueueSender queueSender,
javax.jms.Message message,
java.util.Map deliveryOptionsMap)
Send a message to a queue. |
static java.util.Map |
stringListToMap(java.util.List stringList)
Convert a list of assignment strings to a Map |
static java.lang.String |
stringListToString(java.util.List stringList)
Convert a list of strings to a single string, each separated by "\n" |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static javax.naming.Context getInitialContext(java.util.Map jndiPropertiesMap) throws javax.naming.NamingException
jndiPropertiesMap
- a Map of JNDI properties/values. Common keys for the Map include
java.naming.factory.initial and java.naming.provider.url.
javax.naming.NamingException
- if a naming exception is encounteredpublic static javax.naming.Context getInitialContext(java.util.List jndiPropertiesList) throws javax.naming.NamingException, WavesetException
jndiPropertiesList
- a List of JNDI property assignment strings. Each String in the List must be
of the format <key>=<value>. Most common <key> entries include
java.naming.factory.initial and java.naming.provider.url
WavesetException
- if the property assignment strings contain invalid syntax
javax.naming.NamingException
- if a naming exception is encounteredpublic static java.util.Map stringListToMap(java.util.List stringList) throws WavesetException
stringList
- a List of assignment strings. Each String in the List must be
of the format <key>=<value>.
WavesetException
public static java.lang.String stringListToString(java.util.List stringList)
stringList
- a list of strings
public static void populateMapMessage(javax.jms.MapMessage message, java.util.Map srcMap) throws javax.jms.JMSException
message
- the MapMessage to populatesrcMap
- the Map of values to add to the MapMessage
javax.jms.JMSException
public static javax.jms.QueueConnection createQueueConnection(javax.naming.Context context, java.lang.String factoryName, java.lang.String userName, java.lang.Object password) throws javax.naming.NamingException, javax.jms.JMSException
context
- the Context to use to perform the lookup of the queue connection factoryfactoryName
- the JNDI name of the queue connection factory to use to return
the QueueConnectionuserName
- if userName is present, then an authenticated connection will be performed using the
userName and password provided. If null, the default identity configured for the
factory will be used.password
- used along with userName to perform an authenticated connection. This is
expected to be either an EncryptedData or String instance.
javax.naming.NamingException
- a naming exception occurred looking up the queue connection factory
javax.jms.JMSException
- if JMS Provider fails to create Queue Connection due to some internal error.public static javax.jms.TopicConnection createTopicConnection(javax.naming.Context context, java.lang.String factoryName, java.lang.String userName, java.lang.Object password) throws javax.naming.NamingException, javax.jms.JMSException
context
- the Context to use to perform the lookup of the topic connection factoryfactoryName
- the JNDI name of the topic connection factory to use to return
the TopicConnection
// * @param connOptions an optional Map containing userName and password keys.userName
- If username is supplied, then an authenticated connection will be performed
using the userName and password supplied. Otherwise, the default identity configured for the
factory will be used.password
- If username is supplied, then an authenticated connection will be performed
using the userName and password supplied. Otherwise, the default identity configured for the
factory will be used.
javax.naming.NamingException
- a naming exception occurred looking up the topic connection factory
javax.jms.JMSException
- if JMS Provider fails to create Topic Connection due to some internal error.public static void closeConnection(javax.jms.Connection connection)
Any errors which occur during the close are ignored.
connection
- the QueueConnection or TopicConnection to close.public static void commitSession(javax.jms.Session session) throws javax.jms.JMSException
session
- the Session to commit
javax.jms.JMSException
- if JMS fails to commit the session due to some internal error.public static void rollbackSession(javax.jms.Session session) throws javax.jms.JMSException
session
- the Session to rollback
javax.jms.JMSException
- if JMS fails to rollback the session due to some internal error.public static javax.jms.QueueSession createQueueSession(javax.jms.QueueConnection queueConnection, java.lang.String reliabilityMode) throws javax.jms.JMSException, WavesetException
queueConnection
- the QueueConnection from which the new QueueSession is to be createdreliabilityMode
- specifies the mechanism used to ensure reliable messaging. The valid
values are "LOCAL", "AUTO", "DUPS_OK", and "CLIENT".javax.jms.JMSException
- if JMS Connection fails to create a session due to some internal
error or lack of support for specific transaction and acknowledgement mode.
WavesetException
- if reliabilityMode contains an invalid valuepublic static javax.jms.TopicSession createTopicSession(javax.jms.TopicConnection topicConnection, java.lang.String reliabilityMode) throws javax.jms.JMSException, WavesetException
topicConnection
- the TopicConnection from which the new TopicSession is to be createdreliabilityMode
- specifies the mechanism used to ensure reliable messaging. The valid
values are "LOCAL", "AUTO", "DUPS_OK", and "CLIENT".javax.jms.JMSException
- if JMS Connection fails to create a session due to some internal
error or lack of support for specific transaction and acknowledgement mode.
WavesetException
- if reliabilityMode contains an invalid valuepublic static javax.jms.Queue createQueue(javax.naming.Context context, java.lang.String destinationName) throws WavesetException
context
- the Context to use to perform the lookup of the queuedestinationName
- the JNDI lookup name of the desired queue
WavesetException
- if a naming exception is encountered, or the JNDI lookup does not
return a javax.jms.Queue objectpublic static javax.jms.Topic createTopic(javax.naming.Context context, java.lang.String destinationName) throws WavesetException
context
- the Context to use to perform the lookup of the topicdestinationName
- the JNDI lookup name of the desired Topic
WavesetException
- if a naming exception is encountered, or the JNDI lookup does not
return a javax.jms.Topic objectpublic static javax.jms.QueueSender createQueueSender(javax.jms.QueueSession queueSession, javax.jms.Queue queue) throws javax.jms.JMSException
queueSession
- the session under which messages will be sentqueue
- the queue to send to
javax.jms.JMSException
- if a session fails to create a sender due to some JMS errorpublic static void send(javax.jms.QueueSender queueSender, javax.jms.Message message, java.util.Map deliveryOptionsMap) throws javax.jms.JMSException, WavesetException
queueSender
- the QueueSender which will send the messagemessage
- the message to be sentdeliveryOptionsMap
- Specify a non-null map if you need to specify
delivery mode, priority and time to live options.The table below describes each expected key for the deliveryOptionsMap, and the significance of each key's value.
Key | Value type | Reqd? | Usage | Default |
"deliveryMode" | java.lang.String | no | Valid values are "PERSISTENT" and "NON_PERSISTENT" | "PERSISTENT" |
"priority" | java.lang.String or java.lang.Integer | no | The message priority for this message. Priority must be a value between 0 and 9. JMS defines a 10 level priority value with 0 as the lowest and 9 as the highest. Clients should consider 0-4 as gradients of normal priority and 5-9 as gradients of expedited priority. Priority is set to 4, by default. |
4 |
"timeToLive" | java.lang.String or java.lang.Integer | no | The length of time in milliseconds from its dispatch time that a produced message should be retained by the message system. zero is unlimited. | 0 |
WavesetException
- if illegal values are found in deliveryOptionsMap map
javax.jms.JMSException
- if JMS fails to send the message due to some internal errorpublic static javax.jms.TopicPublisher createTopicPublisher(javax.jms.TopicSession topicSession, javax.jms.Topic topic) throws javax.jms.JMSException
topicSession
- the session under which messages will be publishedtopic
- the topic to publish to
javax.jms.JMSException
- if a session fails to create a publisher due to some JMS errorpublic static void publish(javax.jms.TopicPublisher topicPublisher, javax.jms.Message message, java.util.Map deliveryOptionsMap) throws javax.jms.JMSException, WavesetException
topicPublisher
- the TopicPublisher which will publish the messagemessage
- the message to be publisheddeliveryOptionsMap
- same as described in send
WavesetException
- if illegal values are found in deliveryOptionsMap map
javax.jms.JMSException
- if JMS fails to send the message due to some internal errorpublic static javax.jms.TextMessage createTextMessage(javax.jms.Session session) throws javax.jms.JMSException
session
- the Session from which to create the Message
javax.jms.JMSException
- if JMS fails to create this message due to some internal errorpublic static javax.jms.TextMessage createTextMessage(javax.jms.Session session, java.lang.String text) throws javax.jms.JMSException
session
- the Session from which to create the Messagetext
- the string used to initialize this message
javax.jms.JMSException
- if JMS fails to create this message due to some internal error.public static javax.jms.MapMessage createMapMessage(javax.jms.Session session) throws javax.jms.JMSException
session
- the Session from which to create the Message
javax.jms.JMSException
- if JMS fails to create this message due to some internal error.public static javax.jms.BytesMessage createBytesMessage(javax.jms.Session session) throws javax.jms.JMSException
session
- the Session from which to create the Message
javax.jms.JMSException
- if JMS fails to create this message due to some internal error.public static javax.jms.ObjectMessage createObjectMessage(javax.jms.Session session) throws javax.jms.JMSException
session
- the Session from which to create the Message
javax.jms.JMSException
- if JMS fails to create this message due to some internal error.public static javax.jms.StreamMessage createStreamMessage(javax.jms.Session session) throws javax.jms.JMSException
session
- the Session from which to create the Message
javax.jms.JMSException
- if JMS fails to create this message due to some internal error.public static java.lang.String getMessageDetails(javax.jms.Connection conn, javax.jms.Message msg)
conn
- specify a non-null Connection if you wish to also view
the standard properties exposed by the Connection meta-datamsg
- the Message to detail
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |