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
- MessagingException
public 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
- MessagingException
public javax.jms.Destination createDestination(String name, JMSManager.DestinationType type) throws MessagingException
createDestination(name, type, false, Session.AUTO_ACKNOWLEDGE)
MessagingException
public 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 modeMessagingException
public javax.jms.Message listen(String destName) throws MessagingException
MessagingException
listen(String, String)
public javax.jms.Message listen(String destName, String messageSelector) throws MessagingException
destName
- the Destination to listen onmessageSelector
- selection criteria for filtering messagesException
MessagingException
public javax.jms.Message listen(javax.jms.Destination dest) throws MessagingException
MessagingException
listen(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 messagesException
MessagingException
public javax.jms.Message listen(String destName, int timeout) throws MessagingException
MessagingException
listen(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 outException
MessagingException
public void listen(String destName, javax.jms.MessageListener callback) throws MessagingException
MessagingException
listen(String, String, MessageListener)
public void listen(String destName, String messageSelector, javax.jms.MessageListener callback) throws MessagingException
MessagingException
public void listen(javax.jms.Destination dest, javax.jms.MessageListener callback) throws MessagingException
MessagingException
public void listen(javax.jms.Destination dest, String messageSelector, javax.jms.MessageListener callback) throws MessagingException
MessagingException
public String listenDurable(String topic, javax.jms.MessageListener callback) throws MessagingException
MessagingException
listenDurable(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 subscriptionMessagingException
public void send(String destName, javax.jms.Message msg) throws MessagingException
MessagingException
public void send(javax.jms.Destination dest, javax.jms.Message msg) throws MessagingException
MessagingException
public void send(String destName, Serializable obj) throws MessagingException
MessagingException
public void send(String destName, String messageText) throws MessagingException
MessagingException
public void stop(String destName) throws MessagingException
destName
- MessagingException
public void stopDurable(String subscriptionName) throws MessagingException
subscriptionName
- - the name of the subscriptionMessagingException
public void unsubscribeDurable(String subscriptionName) throws MessagingException
subscriptionName
- - name of the durable subscriptionMessagingException
public void unsubscribeAllDurable() throws MessagingException
MessagingException
public void close() throws MessagingException
MessagingException
public javax.jms.MapMessage createMapMessage(String destName) throws MessagingException
MessagingException
public javax.jms.TextMessage createTextMessage(String destName, String text) throws MessagingException
MessagingException
public javax.jms.ObjectMessage createObjectMessage(String destName, Serializable object) throws MessagingException
MessagingException
public javax.jms.BytesMessage createBytesMessage(String destName) throws MessagingException
MessagingException
public javax.jms.Session getSession(String destName) throws MessagingException
destName
- Exception
MessagingException
public javax.jms.Destination getDestination(String destName) throws MessagingException
destName
- Exception
MessagingException
public List<javax.jms.Destination> getDestinations()
public javax.jms.MessageProducer getProducer(String destName) throws MessagingException
destName
- Exception
MessagingException
public javax.jms.MessageConsumer getConsumer(String destName) throws MessagingException
destName
- Exception
MessagingException
public JMSManager.DestinationType getDefaultDestinationType()
public void setDefaultDestinationType(JMSManager.DestinationType defaultDestinationType)
defaultDestinationType
- protected void connectToJMS(String clientId) throws MessagingException
MessagingException
protected com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination getJMSDestination(String name) throws MessagingException
MessagingException
protected void setupProducer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest) throws MessagingException
MessagingException
protected void setupAsynchConsumer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest, String messageSelector, javax.jms.MessageListener callback) throws MessagingException
MessagingException
protected javax.jms.Message setupSynchConsumer(com.yourmediashelf.fedora.client.messaging.JMSManager.JMSDestination jmsDest, String messageSelector, int timeout) throws MessagingException
MessagingException
protected javax.jms.Message createJMSMessage(Serializable obj, javax.jms.Session session) throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.Connection getConnection() throws MessagingException
MessagingException
protected Object jndiLookup(String name) throws MessagingException
MessagingException
protected Context getContext() throws MessagingException
MessagingException
Copyright © 2010-2013 MediaShelf. All Rights Reserved.