com.atomikos.jms
Class TopicSubscriberSession

java.lang.Object
  extended by com.atomikos.jms.MessageConsumerSession
      extended by com.atomikos.jms.TopicSubscriberSession

public class TopicSubscriberSession
extends MessageConsumerSession

A light-weight alternative for message-driven beans: the TopicReceiverSession allows MessageListener instances to listen on JMS messages in a transactional way (non-transactional mode is not supported). This class is implemented as a JavaBean to facilitate integration in third-party frameworks. This session is long-lived in the sense that underlying JMS resources are refreshed regularly. In particular, clients should not worry about the connection or session timing out. This allows this class to be used for server-type applications.

IMPORTANT: the transactional behaviour guarantees redelivery after failures. As a side-effect, this can lead to so-called poison messages: messages whose processing repeatedly fails due to some recurring error (for instance, a primary key violation in the database, a NullPointerException, ...). Poison messages are problematic because they can prevent other messages from being processed, and block the system. Some messaging systems provide a way to deal with poison messages, others don't. In that case, it is up to the registered MessageListener to detect poison messages. The easiest way to detect these is by inspecting the JMSRedelivered header and/or the (sometimes available) JMS property called JMSXDeliveryCount. For instance, if the delivery count is too high then your application may choose to send the message to a dedicated problem queue and thereby avoid processing errors. Whatever you do, beware that messages are sometimes correctly redelivered, in particular after a prior crash of the application.

Instances of this class consume JMS messages in a single thread only. Use TopicReceiverSessionPool if you want to have multiple concurrent threads for the same topic.

Topic functionality in this product was sponsored by Webtide.


Field Summary
 
Fields inherited from class com.atomikos.jms.MessageConsumerSession
current
 
Constructor Summary
TopicSubscriberSession()
          Creates a new instance to be configured via the setters.
 
Method Summary
protected  String getDestinationName()
           
 boolean getNoLocal()
          Gets the NoLocal flag value.
 String getSubscriberName()
          Gets the subscriber name.
 javax.jms.Topic getTopic()
          Gets the topic to listen on.
 TopicConnectionFactoryBean getTopicConnectionFactoryBean()
          Gets the connection factory used.
 void setNoLocal(boolean value)
          Sets nolocal value (optional).
 void setSubscriberName(String name)
          Sets the durable subscriber name (optional).
 void setTopic(javax.jms.Topic topic)
          Sets the topic to listen on.
 void setTopicConnectionFactoryBean(TopicConnectionFactoryBean factory)
          Sets the connection factory to use.
 
Methods inherited from class com.atomikos.jms.MessageConsumerSession
getAbstractConnectionFactoryBean, getDaemonThreads, getDestination, getExceptionListener, getMessageListener, getMessageSelector, getNotifyListenerOnClose, getTransactionTimeout, getUser, setAbstractConnectionFactoryBean, setDaemonThreads, setDestination, setExceptionListener, setMessageListener, setMessageSelector, setNotifyListenerOnClose, setPassword, setTransactionTimeout, setUser, startListening, startNewThread, stopListening
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TopicSubscriberSession

public TopicSubscriberSession()
Creates a new instance to be configured via the setters.

Method Detail

setTopicConnectionFactoryBean

public void setTopicConnectionFactoryBean(TopicConnectionFactoryBean factory)
Sets the connection factory to use.

Parameters:
factory - This factory needs to be configured independently before this method is called.

getTopicConnectionFactoryBean

public TopicConnectionFactoryBean getTopicConnectionFactoryBean()
Gets the connection factory used.

Returns:

setTopic

public void setTopic(javax.jms.Topic topic)
Sets the topic to listen on.

Parameters:
topic - Transactional receives will come from this topic.

getTopic

public javax.jms.Topic getTopic()
Gets the topic to listen on.

Returns:

getDestinationName

protected String getDestinationName()
Specified by:
getDestinationName in class MessageConsumerSession

getNoLocal

public boolean getNoLocal()
Gets the NoLocal flag value.

Specified by:
getNoLocal in class MessageConsumerSession
Returns:
True if set.

getSubscriberName

public String getSubscriberName()
Gets the subscriber name.

Specified by:
getSubscriberName in class MessageConsumerSession
Returns:
The name, or null if not set.

setNoLocal

public void setNoLocal(boolean value)
Sets nolocal value (optional). If true, then the subscribers will not receive publications made from their connection.

Specified by:
setNoLocal in class MessageConsumerSession
Parameters:
value - Defaults to false.

setSubscriberName

public void setSubscriberName(String name)
Sets the durable subscriber name (optional). If null, no durable subscribers are used.

Specified by:
setSubscriberName in class MessageConsumerSession
Parameters:
name -


Copyright © 2011. All Rights Reserved.