public class DefaultMessenger extends MessengerSupport
DefaultMessenger is the default implementation of
Messenger which uses a ThreadLocal variable
to keep the JMS Session that should be used for a given calling thread.
| Modifier and Type | Field and Description |
|---|---|
private static org.apache.commons.logging.Log |
log
Logger
|
private java.lang.ThreadLocal |
messengerSessionPool
the MessengerSession for each thread
|
private SessionFactory |
sessionFactory
the SessionFactory used to create new JMS sessions
|
private static boolean |
SHARE_CONNECTION |
| Constructor and Description |
|---|
DefaultMessenger() |
| Modifier and Type | Method and Description |
|---|---|
protected MessengerSession |
borrowMessengerSession() |
javax.jms.Message |
call(javax.jms.Destination destination,
javax.jms.Message message)
Sends a message on the given destination and blocks until a response is returned
|
javax.jms.Message |
call(javax.jms.Destination destination,
javax.jms.Message message,
long timeoutMillis)
Sends a message on the given destination and blocks until a response is returned or the given timeout period expires
|
protected void |
clearReplyToDestination()
Clears the temporary destination used to receive reply-to messages
which will lazily force a new destination and consumer to be created next
time a call() method is invoked.
|
void |
close()
Closes the underlying JMS connection
|
protected MessengerSession |
createMessengerSession()
Factory method to create a new MessengerSession
|
javax.jms.ServerSessionPool |
createServerSessionPool(javax.jms.MessageListener messageListener,
int maxThreads)
Creates a new ServerSessionPool implementation with a given maximum number of threads
for use by a ConnectionConsumer
|
protected SessionFactory |
createSessionFactory()
Factory method to create a SessionFactory.
|
javax.jms.Session |
getAsyncSession()
Returns the underlying JMS session that this thread is using for
this Messenger for asynchronous operation such as addMessageListener() operations
|
javax.jms.Connection |
getConnection()
Returns the underlying JMS connection that this Messenger is using
|
protected MessengerSession |
getMessengerSession() |
javax.jms.Queue |
getQueue(javax.jms.QueueSession session,
java.lang.String subject) |
protected javax.jms.MessageConsumer |
getReplyToConsumer() |
protected javax.jms.Destination |
getReplyToDestination() |
javax.jms.Session |
getSession()
Returns the underlying JMS session that this thread is using for
synchronous operations such as send() and receive() for synchronous operation
|
SessionFactory |
getSessionFactory()
Returns the SessionFactory used to create new JMS sessions
|
javax.jms.Topic |
getTopic(javax.jms.TopicSession session,
java.lang.String subject) |
protected boolean |
isTopic(javax.jms.Connection connection) |
protected boolean |
isTopic(javax.jms.ConnectionFactory factory) |
protected void |
returnMessengerSession(MessengerSession session) |
void |
setSessionFactory(SessionFactory sessionFactory)
Sets the SessionFactory used to create new JMS sessions
|
addListener, addListener, borrowMessageConsumer, borrowMessageConsumer, commit, createBrowser, createBrowser, createBytesMessage, createConnectionConsumer, createConnectionConsumer, createConsumer, createConsumer, createMapMessage, createMessage, createMessageConsumer, createMessageConsumer, createMessageProducer, createObjectMessage, createObjectMessage, createStreamMessage, createTemporaryDestination, createTextMessage, createTextMessage, getDeliveryMode, getDeliveryMode, getDestination, getDisableMessageID, getDisableMessageTimestamp, getDurableName, getName, getPriority, getTimeToLive, isCacheProducers, isCacheRequestors, isDurable, isJndiDestinations, isNoLocal, receive, receive, receive, receive, receiveNoWait, receiveNoWait, removeListener, removeListener, returnMessageConsumer, rollback, run, send, send, setCacheProducers, setCacheRequestors, setDeliveryMode, setDeliveryMode, setDisableMessageID, setDisableMessageTimestamp, setDurable, setDurableName, setJndiDestinations, setName, setNoLocal, setPersistentDelivery, setPriority, setTimeToLive, toStringprivate static final boolean SHARE_CONNECTION
private static final org.apache.commons.logging.Log log
private java.lang.ThreadLocal messengerSessionPool
private SessionFactory sessionFactory
public SessionFactory getSessionFactory() throws javax.jms.JMSException
javax.jms.JMSExceptionpublic void setSessionFactory(SessionFactory sessionFactory)
public javax.jms.Connection getConnection()
throws javax.jms.JMSException
MessengergetConnection in interface MessengergetConnection in class MessengerSupportjavax.jms.JMSExceptionpublic javax.jms.ServerSessionPool createServerSessionPool(javax.jms.MessageListener messageListener,
int maxThreads)
throws javax.jms.JMSException
Messengerjavax.jms.JMSExceptionpublic void close()
throws javax.jms.JMSException
Messengerclose in interface Messengerclose in class MessengerSupportjavax.jms.JMSExceptionpublic javax.jms.Session getSession()
throws javax.jms.JMSException
Messengerjavax.jms.JMSExceptionpublic javax.jms.Session getAsyncSession()
throws javax.jms.JMSException
Messengerjavax.jms.JMSExceptionpublic javax.jms.Message call(javax.jms.Destination destination,
javax.jms.Message message)
throws javax.jms.JMSException
Messengerjavax.jms.JMSExceptionpublic javax.jms.Message call(javax.jms.Destination destination,
javax.jms.Message message,
long timeoutMillis)
throws javax.jms.JMSException
Messengerjavax.jms.JMSExceptionprotected boolean isTopic(javax.jms.Connection connection)
throws javax.jms.JMSException
isTopic in class MessengerSupportjavax.jms.JMSExceptionprotected boolean isTopic(javax.jms.ConnectionFactory factory)
throws javax.jms.JMSException
isTopic in class MessengerSupportjavax.jms.JMSExceptionprotected javax.jms.MessageConsumer getReplyToConsumer()
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected void clearReplyToDestination()
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected javax.jms.Destination getReplyToDestination()
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected MessengerSession getMessengerSession() throws javax.jms.JMSException
javax.jms.JMSExceptionprotected MessengerSession borrowMessengerSession() throws javax.jms.JMSException
borrowMessengerSession in class MessengerSupportjavax.jms.JMSExceptionprotected void returnMessengerSession(MessengerSession session)
returnMessengerSession in class MessengerSupportprotected MessengerSession createMessengerSession() throws javax.jms.JMSException
javax.jms.JMSExceptionprotected SessionFactory createSessionFactory() throws javax.jms.JMSException
javax.jms.JMSExceptionpublic javax.jms.Queue getQueue(javax.jms.QueueSession session,
java.lang.String subject)
throws javax.jms.JMSException
getQueue in class MessengerSupportjavax.jms.JMSExceptionpublic javax.jms.Topic getTopic(javax.jms.TopicSession session,
java.lang.String subject)
throws javax.jms.JMSException
getTopic in class MessengerSupportjavax.jms.JMSException