public class JMSManager extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JMSManager.DestinationType |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
connected |
protected javax.jms.Connection |
connection |
static String |
CONNECTION_FACTORY_NAME
Connection Factory Lookup Name
|
protected Map<String,javax.jms.MessageConsumer> |
durableSubscriptions |
protected Hashtable<String,com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination> |
jmsDestinations |
protected Context |
jndi |
| Constructor and Description |
|---|
JMSManager(Properties jndiProps)
Creates a JMS manager using jndi properties to start a connection
to a JMS provider.
|
JMSManager(Properties jndiProps,
String clientId)
Creates a JMS manager using jndi properties to start a connection
to a JMS provider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected void |
connectToJMS(String clientId) |
javax.jms.BytesMessage |
createBytesMessage(String destName) |
javax.jms.Destination |
createDestination(String name,
JMSManager.DestinationType type)
Creates a Destination.
|
javax.jms.Destination |
createDestination(String name,
JMSManager.DestinationType type,
boolean fTransacted,
int ackMode)
Creates a Destination if the Destination has not already been created.
|
protected javax.jms.Message |
createJMSMessage(Serializable obj,
javax.jms.Session session) |
javax.jms.MapMessage |
createMapMessage(String destName) |
javax.jms.ObjectMessage |
createObjectMessage(String destName,
Serializable object) |
javax.jms.TextMessage |
createTextMessage(String destName,
String text) |
protected javax.jms.Connection |
getConnection() |
javax.jms.MessageConsumer |
getConsumer(String destName) |
protected Context |
getContext() |
JMSManager.DestinationType |
getDefaultDestinationType() |
javax.jms.Destination |
getDestination(String destName)
Gets the named Destination if it has been created.
|
List<javax.jms.Destination> |
getDestinations()
Provides a listing of the currently available destinations
|
protected com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination |
getJMSDestination(String name) |
javax.jms.MessageProducer |
getProducer(String destName) |
javax.jms.Session |
getSession(String destName) |
protected Object |
jndiLookup(String name) |
javax.jms.Message |
listen(javax.jms.Destination dest)
Convenience method for synchronous listen with no message selector
|
void |
listen(javax.jms.Destination dest,
javax.jms.MessageListener callback)
This is an asynchronous listen.
|
javax.jms.Message |
listen(javax.jms.Destination dest,
String messageSelector)
This is a synchronous listen.
|
void |
listen(javax.jms.Destination dest,
String messageSelector,
javax.jms.MessageListener callback)
This is an asynchronous listen.
|
javax.jms.Message |
listen(String destName)
Convenience method for synchronous listen with no message selector
|
javax.jms.Message |
listen(String destName,
int timeout)
Convenience method for synchronous listen with no message selector
|
void |
listen(String destName,
javax.jms.MessageListener callback)
Convenience method for asynchronous listen with no message selector
|
javax.jms.Message |
listen(String destName,
String messageSelector)
This is a synchronous listen.
|
javax.jms.Message |
listen(String destName,
String messageSelector,
int timeout)
This is a synchronous listen.
|
void |
listen(String destName,
String messageSelector,
javax.jms.MessageListener callback)
This is an asynchronous listen.
|
String |
listenDurable(String topic,
javax.jms.MessageListener callback) |
String |
listenDurable(String topicName,
javax.jms.MessageListener callback,
String subscriptionName) |
String |
listenDurable(javax.jms.Topic topic,
javax.jms.MessageListener callback)
This is a convenience method to allow a durable subscription to be
created using the topic as the subscription name.
|
String |
listenDurable(javax.jms.Topic topic,
String messageSelector,
javax.jms.MessageListener callback,
String subscriptionName)
This is an asynchronous and durable listen.
|
void |
send(javax.jms.Destination dest,
javax.jms.Message msg)
Allows the caller to send a Message object to a destination
|
void |
send(String destName,
javax.jms.Message msg)
Allows the caller to send a Message object to a named destination
|
void |
send(String destName,
Serializable obj)
Allows the caller to send a Serializable object to a destination
|
void |
send(String destName,
String messageText)
Allows the caller to send text to a destination
|
void |
setDefaultDestinationType(JMSManager.DestinationType defaultDestinationType)
Sets the default DestinationType
|
protected void |
setupAsynchConsumer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest,
String messageSelector,
javax.jms.MessageListener callback) |
protected void |
setupProducer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest) |
protected javax.jms.Message |
setupSynchConsumer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest,
String messageSelector,
int timeout) |
void |
stop(String destName)
Stops producers and consumers on a given destination.
|
void |
stopDurable(String subscriptionName)
Stops a durable message consumer.
|
void |
unsubscribeAllDurable()
Removes all durable topic subscriptions created using
this JMSManager instance
|
void |
unsubscribeDurable(String subscriptionName)
Removes the durable subscription with the given name.
|
public static final String CONNECTION_FACTORY_NAME
protected Context jndi
protected javax.jms.Connection connection
protected boolean connected
protected Hashtable<String,com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination> jmsDestinations
public JMSManager(Properties jndiProps) throws MessagingException
java:comp/env
contextjndiProps - MessagingExceptionpublic JMSManager(Properties jndiProps, String clientId) throws MessagingException
java:comp/env
context
A connection must have a clientId in order to create durable
subscriptions. This clientId can either be set administratively
on the Connection object created in the JNDI store or by providing
a non-null value for the clientId parameter of this method.jndiProps - clientId - MessagingExceptionpublic javax.jms.Destination createDestination(String name, JMSManager.DestinationType type) throws MessagingException
createDestination(name, type, false, Session.AUTO_ACKNOWLEDGE)MessagingExceptionpublic javax.jms.Destination createDestination(String name, JMSManager.DestinationType type, boolean fTransacted, int ackMode) throws MessagingException
name - - the name of the destination to createtype - - the destination type (topic or queue)fTransacted - - determines whether the session will maintain transactionsackMode - - determines the session acknowledgment modeMessagingExceptionpublic javax.jms.Message listen(String destName) throws MessagingException
MessagingExceptionlisten(String, String)public javax.jms.Message listen(String destName, String messageSelector) throws MessagingException
destName - the Destination to listen onmessageSelector - selection criteria for filtering messagesExceptionMessagingExceptionpublic javax.jms.Message listen(javax.jms.Destination dest)
throws MessagingException
MessagingExceptionlisten(Destination, String)public javax.jms.Message listen(javax.jms.Destination dest,
String messageSelector)
throws MessagingException
dest - the Destination to listen onmessageSelector - selection criteria for filtering messagesExceptionMessagingExceptionpublic javax.jms.Message listen(String destName, int timeout) throws MessagingException
MessagingExceptionlisten(String, String, int)public javax.jms.Message listen(String destName, String messageSelector, int timeout) throws MessagingException
destName - the Destination to listen onmessageSelector - selection criteria for filtering messagestimeout - time in milliseconds before timing outExceptionMessagingExceptionpublic void listen(String destName, javax.jms.MessageListener callback) throws MessagingException
MessagingExceptionlisten(String, String, MessageListener)public void listen(String destName, String messageSelector, javax.jms.MessageListener callback) throws MessagingException
MessagingExceptionpublic void listen(javax.jms.Destination dest,
javax.jms.MessageListener callback)
throws MessagingException
MessagingExceptionpublic void listen(javax.jms.Destination dest,
String messageSelector,
javax.jms.MessageListener callback)
throws MessagingException
MessagingExceptionpublic String listenDurable(String topic, javax.jms.MessageListener callback) throws MessagingException
MessagingExceptionlistenDurable(Topic, MessageListener)public String listenDurable(String topicName, javax.jms.MessageListener callback, String subscriptionName) throws MessagingException
public String listenDurable(javax.jms.Topic topic, javax.jms.MessageListener callback) throws MessagingException
listenDurable(topic, "", callback, null)public String listenDurable(javax.jms.Topic topic, String messageSelector, javax.jms.MessageListener callback, String subscriptionName) throws MessagingException
topic - the topic on which to listenmessageSelector - selection criteria for filtering messagescallback - the listener to call when a message is receivedsubscriptionName - the name of the subscriptionMessagingExceptionpublic void send(String destName, javax.jms.Message msg) throws MessagingException
MessagingExceptionpublic void send(javax.jms.Destination dest,
javax.jms.Message msg)
throws MessagingException
MessagingExceptionpublic void send(String destName, Serializable obj) throws MessagingException
MessagingExceptionpublic void send(String destName, String messageText) throws MessagingException
MessagingExceptionpublic void stop(String destName) throws MessagingException
destName - MessagingExceptionpublic void stopDurable(String subscriptionName) throws MessagingException
subscriptionName - - the name of the subscriptionMessagingExceptionpublic void unsubscribeDurable(String subscriptionName) throws MessagingException
subscriptionName - - name of the durable subscriptionMessagingExceptionpublic void unsubscribeAllDurable()
throws MessagingException
MessagingExceptionpublic void close()
throws MessagingException
MessagingExceptionpublic javax.jms.MapMessage createMapMessage(String destName) throws MessagingException
MessagingExceptionpublic javax.jms.TextMessage createTextMessage(String destName, String text) throws MessagingException
MessagingExceptionpublic javax.jms.ObjectMessage createObjectMessage(String destName, Serializable object) throws MessagingException
MessagingExceptionpublic javax.jms.BytesMessage createBytesMessage(String destName) throws MessagingException
MessagingExceptionpublic javax.jms.Session getSession(String destName) throws MessagingException
destName - ExceptionMessagingExceptionpublic javax.jms.Destination getDestination(String destName) throws MessagingException
destName - ExceptionMessagingExceptionpublic List<javax.jms.Destination> getDestinations()
public javax.jms.MessageProducer getProducer(String destName) throws MessagingException
destName - ExceptionMessagingExceptionpublic javax.jms.MessageConsumer getConsumer(String destName) throws MessagingException
destName - ExceptionMessagingExceptionpublic JMSManager.DestinationType getDefaultDestinationType()
public void setDefaultDestinationType(JMSManager.DestinationType defaultDestinationType)
defaultDestinationType - protected void connectToJMS(String clientId) throws MessagingException
MessagingExceptionprotected com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination getJMSDestination(String name) throws MessagingException
MessagingExceptionprotected void setupProducer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest)
throws MessagingException
MessagingExceptionprotected void setupAsynchConsumer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest,
String messageSelector,
javax.jms.MessageListener callback)
throws MessagingException
MessagingExceptionprotected javax.jms.Message setupSynchConsumer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest,
String messageSelector,
int timeout)
throws MessagingException
MessagingExceptionprotected javax.jms.Message createJMSMessage(Serializable obj, javax.jms.Session session) throws javax.jms.JMSException
javax.jms.JMSExceptionprotected javax.jms.Connection getConnection()
throws MessagingException
MessagingExceptionprotected Object jndiLookup(String name) throws MessagingException
MessagingExceptionprotected Context getContext() throws MessagingException
MessagingExceptionCopyright © 2010-2013 MediaShelf. All Rights Reserved.