org.apache.commons.messenger
Class SimpleMessenger

java.lang.Object
  extended by org.apache.commons.messenger.MessengerSupport
      extended by org.apache.commons.messenger.SimpleMessenger
All Implemented Interfaces:
Messenger

public class SimpleMessenger
extends MessengerSupport

SimpleMessenger is an implementation of Messenger which uses a single JMS Session for sending to keep the JMS Session that should be used for a given calling thread.

Version:
$Revision: 155459 $
Author:
James Strachan

Nested Class Summary
protected static class SimpleMessenger.ThreadLocalData
           
 
Constructor Summary
SimpleMessenger()
           
 
Method Summary
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
 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
 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
protected  SimpleMessenger.ThreadLocalData getThreadLocalData(javax.jms.Session session)
           
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
 
Methods inherited from class org.apache.commons.messenger.MessengerSupport
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, getQueue, getTimeToLive, getTopic, 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, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleMessenger

public SimpleMessenger()
Method Detail

getSessionFactory

public SessionFactory getSessionFactory()
                                 throws javax.jms.JMSException
Returns the SessionFactory used to create new JMS sessions

Throws:
javax.jms.JMSException

setSessionFactory

public void setSessionFactory(SessionFactory sessionFactory)
Sets the SessionFactory used to create new JMS sessions


getConnection

public javax.jms.Connection getConnection()
                                   throws javax.jms.JMSException
Description copied from interface: Messenger
Returns the underlying JMS connection that this Messenger is using

Specified by:
getConnection in interface Messenger
Specified by:
getConnection in class MessengerSupport
Throws:
javax.jms.JMSException

createServerSessionPool

public javax.jms.ServerSessionPool createServerSessionPool(javax.jms.MessageListener messageListener,
                                                           int maxThreads)
                                                    throws javax.jms.JMSException
Description copied from interface: Messenger
Creates a new ServerSessionPool implementation with a given maximum number of threads for use by a ConnectionConsumer

Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Description copied from interface: Messenger
Closes the underlying JMS connection

Specified by:
close in interface Messenger
Overrides:
close in class MessengerSupport
Throws:
javax.jms.JMSException

getSession

public javax.jms.Session getSession()
                             throws javax.jms.JMSException
Description copied from interface: Messenger
Returns the underlying JMS session that this thread is using for synchronous operations such as send() and receive() for synchronous operation

Throws:
javax.jms.JMSException

getAsyncSession

public javax.jms.Session getAsyncSession()
                                  throws javax.jms.JMSException
Description copied from interface: Messenger
Returns the underlying JMS session that this thread is using for this Messenger for asynchronous operation such as addMessageListener() operations

Throws:
javax.jms.JMSException

call

public javax.jms.Message call(javax.jms.Destination destination,
                              javax.jms.Message message)
                       throws javax.jms.JMSException
Description copied from interface: Messenger
Sends a message on the given destination and blocks until a response is returned

Throws:
javax.jms.JMSException

call

public javax.jms.Message call(javax.jms.Destination destination,
                              javax.jms.Message message,
                              long timeoutMillis)
                       throws javax.jms.JMSException
Description copied from interface: Messenger
Sends a message on the given destination and blocks until a response is returned or the given timeout period expires

Throws:
javax.jms.JMSException

getThreadLocalData

protected SimpleMessenger.ThreadLocalData getThreadLocalData(javax.jms.Session session)
                                                      throws javax.jms.JMSException
Returns:
the local thread data
Throws:
javax.jms.JMSException

isTopic

protected boolean isTopic(javax.jms.Connection connection)
                   throws javax.jms.JMSException
Specified by:
isTopic in class MessengerSupport
Throws:
javax.jms.JMSException

isTopic

protected boolean isTopic(javax.jms.ConnectionFactory factory)
                   throws javax.jms.JMSException
Specified by:
isTopic in class MessengerSupport
Throws:
javax.jms.JMSException

createMessengerSession

protected MessengerSession createMessengerSession()
                                           throws javax.jms.JMSException
Factory method to create a new MessengerSession

Throws:
javax.jms.JMSException

createSessionFactory

protected SessionFactory createSessionFactory()
                                       throws javax.jms.JMSException
Factory method to create a SessionFactory. Derived classes could override this method to create the SessionFactory from a well known place

Throws:
javax.jms.JMSException

borrowMessengerSession

protected MessengerSession borrowMessengerSession()
                                           throws javax.jms.JMSException
Specified by:
borrowMessengerSession in class MessengerSupport
Throws:
javax.jms.JMSException

returnMessengerSession

protected void returnMessengerSession(MessengerSession session)
Specified by:
returnMessengerSession in class MessengerSupport


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.