org.apache.commons.messenger
Interface Messenger

All Known Implementing Classes:
DefaultMessenger, MessengerSupport, SimpleMessenger, XAMessenger

public interface Messenger

Messenger a facade over the JMS API making it easy to use JMS and hiding much of the complexity of threading and configuration. A Messenger will internally associate a JMS Session with the calling thread so that all methods called in the same thread (such as inside a Servlet or taglib) will use the same JMS Session.

Version:
$Revision: 155459 $
Author:
James Strachan

Method Summary
 void addListener(javax.jms.Destination destination, javax.jms.MessageListener listener)
          Adds a message listener on the given destination
 void addListener(javax.jms.Destination destination, String selector, javax.jms.MessageListener listener)
           
 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
 void commit()
          Commits all messages done in this thread and releases any locks
 javax.jms.QueueBrowser createBrowser(javax.jms.Destination destination)
          Creates a QueueBrowser for the given Queue
 javax.jms.BytesMessage createBytesMessage()
           
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          Creates a ConnectionConsumer which is useful if used inside an application server to associate multiple threads with consuming from a JMS destination
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, String selector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          Creates a ConnectionConsumer which is useful if used inside an application server to associate multiple threads with consuming from a JMS destination
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
          Creates a MessageConsumer for the given JMS Desintation
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String selector)
          Creates a MessageConsumer for the given JMS Desintation and JMS selector
 javax.jms.MapMessage createMapMessage()
           
 javax.jms.Message createMessage()
           
 javax.jms.ObjectMessage createObjectMessage()
           
 javax.jms.ObjectMessage createObjectMessage(Serializable object)
           
 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
 javax.jms.StreamMessage createStreamMessage()
           
 javax.jms.Destination createTemporaryDestination()
          Returns a new temporary destination
 javax.jms.TextMessage createTextMessage()
           
 javax.jms.TextMessage createTextMessage(String text)
           
 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
 int getDeliveryMode(javax.jms.Destination destination)
           
 javax.jms.Destination getDestination(String subject)
          Returns the destination for the given subject name
 boolean getDisableMessageID(javax.jms.Destination destination)
           
 boolean getDisableMessageTimestamp(javax.jms.Destination destination)
           
 String getName()
          Temporary hack - this method has been added so that Messenger works better with the digester
 int getPriority(javax.jms.Destination destination)
           
 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 and Connections.
 long getTimeToLive(javax.jms.Destination destination)
           
 javax.jms.Message receive(javax.jms.Destination destination)
          Receives a message on the given destination, blocking until one is returned
 javax.jms.Message receive(javax.jms.Destination destination, long timeoutMillis)
          Receives a message on the given destination, blocking for the specified timeout
 javax.jms.Message receive(javax.jms.Destination destination, String selector)
          Receives a message on the given destination and message selector, blocking until one is returned
 javax.jms.Message receive(javax.jms.Destination destination, String selector, long timeoutMillis)
          Receives a message on the given destination and selector, blocking for the specified timeout
 javax.jms.Message receiveNoWait(javax.jms.Destination destination)
          Receives a message on the given destination without blocking or returns null
 javax.jms.Message receiveNoWait(javax.jms.Destination destination, String selector)
          Receives a message on the given destination and selector without blocking or returns null
 void removeListener(javax.jms.Destination destination, javax.jms.MessageListener listener)
           
 void removeListener(javax.jms.Destination destination, String selector, javax.jms.MessageListener listener)
           
 void rollback()
          Rolls back any messages done in this thread and releases any locks
 void run()
          Allows this current thread to be given to the JMS connection to process messages.
 void send(javax.jms.Destination destination, javax.jms.Message message)
          Sends a message on the given destination
 void setDeliveryMode(javax.jms.Destination destination, int deliveryMode)
           
 void setDisableMessageID(javax.jms.Destination destination, boolean value)
           
 void setDisableMessageTimestamp(javax.jms.Destination destination, boolean value)
           
 void setPriority(javax.jms.Destination destination, int defaultPriority)
           
 void setTimeToLive(javax.jms.Destination destination, long timeToLive)
           
 

Method Detail

getName

String getName()
Temporary hack - this method has been added so that Messenger works better with the digester


getDestination

javax.jms.Destination getDestination(String subject)
                                     throws javax.jms.JMSException
Returns the destination for the given subject name

Throws:
javax.jms.JMSException

createTemporaryDestination

javax.jms.Destination createTemporaryDestination()
                                                 throws javax.jms.JMSException
Returns a new temporary destination

Throws:
javax.jms.JMSException

send

void send(javax.jms.Destination destination,
          javax.jms.Message message)
          throws javax.jms.JMSException
Sends a message on the given destination

Throws:
javax.jms.JMSException

call

javax.jms.Message call(javax.jms.Destination destination,
                       javax.jms.Message message)
                       throws javax.jms.JMSException
Sends a message on the given destination and blocks until a response is returned

Throws:
javax.jms.JMSException

call

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

Throws:
javax.jms.JMSException

receive

javax.jms.Message receive(javax.jms.Destination destination)
                          throws javax.jms.JMSException
Receives a message on the given destination, blocking until one is returned

Throws:
javax.jms.JMSException

receive

javax.jms.Message receive(javax.jms.Destination destination,
                          String selector)
                          throws javax.jms.JMSException
Receives a message on the given destination and message selector, blocking until one is returned

Throws:
javax.jms.JMSException

receive

javax.jms.Message receive(javax.jms.Destination destination,
                          long timeoutMillis)
                          throws javax.jms.JMSException
Receives a message on the given destination, blocking for the specified timeout

Throws:
javax.jms.JMSException

receive

javax.jms.Message receive(javax.jms.Destination destination,
                          String selector,
                          long timeoutMillis)
                          throws javax.jms.JMSException
Receives a message on the given destination and selector, blocking for the specified timeout

Throws:
javax.jms.JMSException

receiveNoWait

javax.jms.Message receiveNoWait(javax.jms.Destination destination)
                                throws javax.jms.JMSException
Receives a message on the given destination without blocking or returns null

Throws:
javax.jms.JMSException

receiveNoWait

javax.jms.Message receiveNoWait(javax.jms.Destination destination,
                                String selector)
                                throws javax.jms.JMSException
Receives a message on the given destination and selector without blocking or returns null

Throws:
javax.jms.JMSException

createConsumer

javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Creates a MessageConsumer for the given JMS Desintation

Throws:
javax.jms.JMSException

createConsumer

javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                         String selector)
                                         throws javax.jms.JMSException
Creates a MessageConsumer for the given JMS Desintation and JMS selector

Throws:
javax.jms.JMSException

createBrowser

javax.jms.QueueBrowser createBrowser(javax.jms.Destination destination)
                                     throws javax.jms.JMSException
Creates a QueueBrowser for the given Queue

Throws:
javax.jms.JMSException

run

void run()
Allows this current thread to be given to the JMS connection to process messages. This method can be useful for creating background processing threads


getConnection

javax.jms.Connection getConnection()
                                   throws javax.jms.JMSException
Returns the underlying JMS connection that this Messenger is using

Throws:
javax.jms.JMSException

getSession

javax.jms.Session getSession()
                             throws javax.jms.JMSException
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

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

Throws:
javax.jms.JMSException

createConnectionConsumer

javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination,
                                                      javax.jms.ServerSessionPool sessionPool,
                                                      int maxMessages)
                                                      throws javax.jms.JMSException
Creates a ConnectionConsumer which is useful if used inside an application server to associate multiple threads with consuming from a JMS destination

Throws:
javax.jms.JMSException

createConnectionConsumer

javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination,
                                                      String selector,
                                                      javax.jms.ServerSessionPool sessionPool,
                                                      int maxMessages)
                                                      throws javax.jms.JMSException
Creates a ConnectionConsumer which is useful if used inside an application server to associate multiple threads with consuming from a JMS destination

Throws:
javax.jms.JMSException

createServerSessionPool

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

Throws:
javax.jms.JMSException

addListener

void addListener(javax.jms.Destination destination,
                 javax.jms.MessageListener listener)
                 throws javax.jms.JMSException
Adds a message listener on the given destination

Throws:
javax.jms.JMSException

addListener

void addListener(javax.jms.Destination destination,
                 String selector,
                 javax.jms.MessageListener listener)
                 throws javax.jms.JMSException
Throws:
javax.jms.JMSException

removeListener

void removeListener(javax.jms.Destination destination,
                    javax.jms.MessageListener listener)
                    throws javax.jms.JMSException
Throws:
javax.jms.JMSException

removeListener

void removeListener(javax.jms.Destination destination,
                    String selector,
                    javax.jms.MessageListener listener)
                    throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createBytesMessage

javax.jms.BytesMessage createBytesMessage()
                                          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createMapMessage

javax.jms.MapMessage createMapMessage()
                                      throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createMessage

javax.jms.Message createMessage()
                                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createObjectMessage

javax.jms.ObjectMessage createObjectMessage()
                                            throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createObjectMessage

javax.jms.ObjectMessage createObjectMessage(Serializable object)
                                            throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createStreamMessage

javax.jms.StreamMessage createStreamMessage()
                                            throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createTextMessage

javax.jms.TextMessage createTextMessage()
                                        throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createTextMessage

javax.jms.TextMessage createTextMessage(String text)
                                        throws javax.jms.JMSException
Throws:
javax.jms.JMSException

commit

void commit()
            throws javax.jms.JMSException
Commits all messages done in this thread and releases any locks

Throws:
javax.jms.JMSException

rollback

void rollback()
              throws javax.jms.JMSException
Rolls back any messages done in this thread and releases any locks

Throws:
javax.jms.JMSException

close

void close()
           throws javax.jms.JMSException
Closes the underlying JMS connection

Throws:
javax.jms.JMSException

getSessionFactory

SessionFactory getSessionFactory()
                                 throws javax.jms.JMSException
Returns the SessionFactory used to create new JMS sessions and Connections. This allows things like transaction mode to be configured before sessions are created.

Throws:
javax.jms.JMSException

getDeliveryMode

int getDeliveryMode(javax.jms.Destination destination)
                    throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getDisableMessageID

boolean getDisableMessageID(javax.jms.Destination destination)
                            throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getDisableMessageTimestamp

boolean getDisableMessageTimestamp(javax.jms.Destination destination)
                                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getPriority

int getPriority(javax.jms.Destination destination)
                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

getTimeToLive

long getTimeToLive(javax.jms.Destination destination)
                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setDeliveryMode

void setDeliveryMode(javax.jms.Destination destination,
                     int deliveryMode)
                     throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setDisableMessageID

void setDisableMessageID(javax.jms.Destination destination,
                         boolean value)
                         throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setDisableMessageTimestamp

void setDisableMessageTimestamp(javax.jms.Destination destination,
                                boolean value)
                                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setPriority

void setPriority(javax.jms.Destination destination,
                 int defaultPriority)
                 throws javax.jms.JMSException
Throws:
javax.jms.JMSException

setTimeToLive

void setTimeToLive(javax.jms.Destination destination,
                   long timeToLive)
                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException


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