com.atomikos.jms
Class MessageConsumerSession

java.lang.Object
  extended by com.atomikos.jms.MessageConsumerSession
Direct Known Subclasses:
QueueReceiverSession, TopicSubscriberSession

public abstract class MessageConsumerSession
extends Object

Common message-driven session functionality.


Field Summary
protected  Thread current
           
 
Constructor Summary
protected MessageConsumerSession()
           
 
Method Summary
protected  AbstractConnectionFactoryBean getAbstractConnectionFactoryBean()
           
 boolean getDaemonThreads()
          Tests whether threads are daemon threads.
 javax.jms.Destination getDestination()
          Gets the destination.
protected abstract  String getDestinationName()
           
 javax.jms.ExceptionListener getExceptionListener()
          Gets the exception listener (if any).
 javax.jms.MessageListener getMessageListener()
          Get the message listener of this session, if any.
 String getMessageSelector()
          Get the message selector (if any)
protected abstract  boolean getNoLocal()
           
 boolean getNotifyListenerOnClose()
          Check wether the session is configured to notify the listener upon close.
protected abstract  String getSubscriberName()
           
 int getTransactionTimeout()
          Get the transaction timeout in seconds.
 String getUser()
          Get the user to connect with.
protected  void setAbstractConnectionFactoryBean(AbstractConnectionFactoryBean bean)
           
 void setDaemonThreads(boolean value)
          Sets whether threads should be daemon threads or not.
 void setDestination(javax.jms.Destination destination)
          Sets the destination to listen on.
 void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
          Sets the exception listener.
 void setMessageListener(javax.jms.MessageListener listener)
          Set the message listener for this session.
 void setMessageSelector(String selector)
          Set the message selector to use.
protected abstract  void setNoLocal(boolean value)
           
 void setNotifyListenerOnClose(boolean b)
          Set whether the listener should be notified on close.
 void setPassword(String password)
          Set the password to use for connecting.
protected abstract  void setSubscriberName(String name)
           
 void setTransactionTimeout(int seconds)
          Set the transaction timeout, after which long transactions are rolled back automatically.
 void setUser(String user)
          Set the user to create connections with.
 void startListening()
          Start listening for messages.
protected  void startNewThread()
           
 void stopListening()
          Stop listening for messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

protected transient Thread current
Constructor Detail

MessageConsumerSession

protected MessageConsumerSession()
Method Detail

getSubscriberName

protected abstract String getSubscriberName()

setSubscriberName

protected abstract void setSubscriberName(String name)

setNoLocal

protected abstract void setNoLocal(boolean value)

getNoLocal

protected abstract boolean getNoLocal()

setAbstractConnectionFactoryBean

protected void setAbstractConnectionFactoryBean(AbstractConnectionFactoryBean bean)

getAbstractConnectionFactoryBean

protected AbstractConnectionFactoryBean getAbstractConnectionFactoryBean()

setDaemonThreads

public void setDaemonThreads(boolean value)
Sets whether threads should be daemon threads or not. Default is false.

Parameters:
value - If true then threads will be daemon threads.

getDaemonThreads

public boolean getDaemonThreads()
Tests whether threads are daemon threads.

Returns:
True if threads are deamons.

getMessageSelector

public String getMessageSelector()
Get the message selector (if any)

Returns:
The selector, or null if none.

setMessageSelector

public void setMessageSelector(String selector)
Set the message selector to use.

Parameters:
selector -

setUser

public void setUser(String user)
Set the user to create connections with. If the user is not set then the default connection will be used.

Parameters:
user -

getUser

public String getUser()
Get the user to connect with.

Returns:
The user or null if no explicit authentication is to be used.

setPassword

public void setPassword(String password)
Set the password to use for connecting. This property only needs to be set if the User property was also set.

Parameters:
password -

getDestination

public javax.jms.Destination getDestination()
Gets the destination.

Returns:
Null if none was set.

setDestination

public void setDestination(javax.jms.Destination destination)
Sets the destination to listen on.

Parameters:
destination -

setTransactionTimeout

public void setTransactionTimeout(int seconds)
Set the transaction timeout, after which long transactions are rolled back automatically. The transaction timeout indirectly determines how long an incoming message can remain in the queue before it is detected by the listener threads. A smaller value means that listener threads will be more actively checking the queues, but this implies a faster invalidation of active transactions due to timeout, and more thread overhead.

Parameters:
seconds - The timeout for transactions started by the session.

getTransactionTimeout

public int getTransactionTimeout()
Get the transaction timeout in seconds.

Returns:

setMessageListener

public void setMessageListener(javax.jms.MessageListener listener)
Set the message listener for this session. Only one message listener per session is allowed. After this method is called, the listener will receive incoming messages in its onMessage method, in a JTA transaction. By default, the receiver will commit the transaction unless the onMessage method throws a runtime exception (in which case rollback will happen). If no more messages are desired, then this method should be called a second time with a null argument.

Parameters:
listener -

getMessageListener

public javax.jms.MessageListener getMessageListener()
Get the message listener of this session, if any.

Returns:

startListening

public void startListening()
                    throws javax.jms.JMSException,
                           SystemException
Start listening for messages.

Throws:
javax.jms.JMSException
SystemException

getDestinationName

protected abstract String getDestinationName()

startNewThread

protected void startNewThread()

stopListening

public void stopListening()
Stop listening for messages. If notifyListenerOnClose is set then calling this method will indirectly lead to the invocation of the listener's onMessage method with a null argument (and without a transaction). This allows receivers to detect shutdown.


getNotifyListenerOnClose

public boolean getNotifyListenerOnClose()
Check wether the session is configured to notify the listener upon close.

Returns:
boolean If true then the listener will receive a null message when the session is closed.

setNotifyListenerOnClose

public void setNotifyListenerOnClose(boolean b)
Set whether the listener should be notified on close.

Parameters:
b -

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
Gets the exception listener (if any).

Returns:
Null if no ExceptionListener was set.

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
Sets the exception listener. The listener will be notified of connection-level JMS errors. IMPORTANT: exception listeners will NOT be notified of any errors thrown by the MessageListener. Instead, the ExceptionListener mechanism is meant for system-level connectivity errors towards and from the underlying message system.

Parameters:
exceptionListener -


Copyright © 2011. All Rights Reserved.