com.atomikos.jms
Class MessageConsumerSessionPool

java.lang.Object
  extended by com.atomikos.jms.MessageConsumerSessionPool
Direct Known Subclasses:
QueueReceiverSessionPool, TopicSubscriberSessionPool

public abstract class MessageConsumerSessionPool
extends Object

Common functionality for pooled listener sessions.


Constructor Summary
protected MessageConsumerSessionPool()
           
 
Method Summary
protected abstract  MessageConsumerSession createSession()
           
protected  AbstractConnectionFactoryBean getAbstractConnectionFactoryBean()
           
 boolean getDaemonThreads()
          Tests whether threads are daemon threads.
protected  javax.jms.Destination getDestination()
           
 javax.jms.ExceptionListener getExceptionListener()
          Gets the exception listener (if any).
 javax.jms.MessageListener getMessageListener()
          Get the message listener if any.
 String getMessageSelector()
          Get the message selector (if any)
protected abstract  boolean getNoLocal()
           
 boolean getNotifyListenerOnClose()
          Getter to check whether the listener is notified on close.
 int getPoolSize()
          Get the size of the pool.
protected abstract  String getSubscriberName()
           
 int getTransactionTimeout()
          Get the transaction timeout.
 String getUser()
          Get the user for connecting, or null if the default user should be used.
protected  void setAbstractConnectionFactoryBean(AbstractConnectionFactoryBean bean)
           
 void setDaemonThreads(boolean value)
          Sets whether threads should be daemon threads or not (optional).
protected  void setDestination(javax.jms.Destination dest)
           
 void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
          Sets the exception listener.
 void setMessageListener(javax.jms.MessageListener listener)
          Set the message listener to use (required).
 void setMessageSelector(String selector)
          Set the message selector to use (optional).
 void setNotifyListenerOnClose(boolean b)
          Set whether the listener should be notified of close events on the pool (optional).
 void setPassword(String string)
          Set the password if explicit authentication is needed (optional).
 void setPoolSize(int i)
          Sets the size of the session pool.
 void setTransactionTimeout(int i)
          Set the transaction timeout in seconds (optional).
 void setUser(String string)
          Set the user to use for explicit authentication (optional).
 void start()
          Start listening for messages.
 void stop()
          Stop listening for messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageConsumerSessionPool

protected MessageConsumerSessionPool()
Method Detail

setAbstractConnectionFactoryBean

protected void setAbstractConnectionFactoryBean(AbstractConnectionFactoryBean bean)

getAbstractConnectionFactoryBean

protected AbstractConnectionFactoryBean getAbstractConnectionFactoryBean()

getDestination

protected javax.jms.Destination getDestination()

setDestination

protected void setDestination(javax.jms.Destination dest)

setDaemonThreads

public void setDaemonThreads(boolean value)
Sets whether threads should be daemon threads or not (optional). 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.

getMessageListener

public javax.jms.MessageListener getMessageListener()
Get the message listener if any.

Returns:

getTransactionTimeout

public int getTransactionTimeout()
Get the transaction timeout.

Returns:

getUser

public String getUser()
Get the user for connecting, or null if the default user should be used.

Returns:

setMessageListener

public void setMessageListener(javax.jms.MessageListener listener)
Set the message listener to use (required). The same instance will be used for each session in the pool, meaning that instances need to be thread-safe. Only one listener is allowed at a time. Call this method with a null argument to unset the listener.

Parameters:
listener -

setPassword

public void setPassword(String string)
Set the password if explicit authentication is needed (optional). You need to set this if the user is also set.

Parameters:
string -

setTransactionTimeout

public void setTransactionTimeout(int i)
Set the transaction timeout in seconds (optional).

Parameters:
i -

setUser

public void setUser(String string)
Set the user to use for explicit authentication (optional). Don't set this property if you want to use the default authentication.

Parameters:
string -

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 (optional).

Parameters:
selector -

getPoolSize

public int getPoolSize()
Get the size of the pool.

Returns:

setPoolSize

public void setPoolSize(int i)
Sets the size of the session pool.

Parameters:
i -

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.

Parameters:
exceptionListener -

createSession

protected abstract MessageConsumerSession createSession()

getNoLocal

protected abstract boolean getNoLocal()

getSubscriberName

protected abstract String getSubscriberName()

start

public void start()
           throws javax.jms.JMSException
Start listening for messages.

Throws:
javax.jms.JMSException

stop

public void stop()
Stop listening for messages. If notifyListenerOnClose is set then calling this method will notify the listener by calling its onMessage method with a null argument (and also without transaction context).


getNotifyListenerOnClose

public boolean getNotifyListenerOnClose()
Getter to check whether the listener is notified on close.

Returns:

setNotifyListenerOnClose

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

Parameters:
b - If true, then the listener will receive a null message if the pool is closed.


Copyright © 2011. All Rights Reserved.