|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atomikos.jms.extra.MessageDrivenContainer
public class MessageDrivenContainer
A message-driven container for asynchronously receiving JMS messages from a topic or queue, within a managed JTA transaction context. Upon start, an instance of this class will create a number of concurrent sessions that listen for incoming messages on the same destination. MessageListener instances should be thread-safe if the pool size is larger than one. Note: in general, after start() any changed properties are only effective on the next start() event.
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. To avoid poison messages, make sure that your MessageListener implementation only throws a RuntimeException when the problem is transient. In that case, the system will perform rollback and the message will be redelivered facing a clean system state. All non-transient errors (i.e., those that happen each time a message is delivered) indicate problems at the application level and should be dealt with by writing better application code.
Constructor Summary | |
---|---|
MessageDrivenContainer()
|
Method Summary | |
---|---|
AtomikosConnectionFactoryBean |
getAtomikosConnectionFactoryBean()
|
boolean |
getDaemonThreads()
Tests whether threads are daemon threads. |
javax.jms.Destination |
getDestination()
Gets the destination. |
String |
getDestinationName()
Gets the destination name. |
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 boolean |
getNoLocal()
|
boolean |
getNotifyListenerOnClose()
Getter to check whether the listener is notified on close. |
int |
getPoolSize()
Get the size of the pool. |
String |
getSubscriberName()
Gets the subscriber name (for durable subscribers). |
int |
getTransactionTimeout()
Get the transaction timeout. |
boolean |
getUnsubscribeOnClose()
Getter to test if unsubscribe should be called on close. |
String |
getUser()
Get the user for connecting, or null if the default user should be used. |
boolean |
isNoLocal()
Test if this instance will receive sends from the same connection. |
void |
setAtomikosConnectionFactoryBean(AtomikosConnectionFactoryBean bean)
Sets the connection factory to use. |
void |
setClientID(String clientID)
Sets the clientID for durable subscriptions. |
void |
setDaemonThreads(boolean value)
Sets whether threads should be daemon threads or not (optional). |
void |
setDestination(javax.jms.Destination dest)
Sets the JMS destination to listen on (required unless the destinationName is set instead). |
void |
setDestinationName(String destinationName)
Sets the JMS provider-specific destination name (required unless the destination is set directly). |
void |
setExceptionListener(javax.jms.ExceptionListener exceptionListener)
Sets the exception listener (optional). |
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 |
setNoLocal(boolean noLocal)
Sets whether or not this topic should receive sends from the same connection (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 size)
Sets the size of the session pool (optional). |
void |
setSubscriberName(String subscriberName)
Sets the name to use for durable subscriptions (optional). |
void |
setTransactionTimeout(int i)
Set the transaction timeout in seconds (optional). |
void |
setUnsubscribeOnClose(boolean b)
Sets whether unsubscribe should be done at closing time (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 |
---|
public MessageDrivenContainer()
Method Detail |
---|
public void setClientID(String clientID)
clientID
- public void setAtomikosConnectionFactoryBean(AtomikosConnectionFactoryBean bean)
bean
- public AtomikosConnectionFactoryBean getAtomikosConnectionFactoryBean()
public javax.jms.Destination getDestination()
public void setDestination(javax.jms.Destination dest)
dest
- public String getDestinationName()
public void setDestinationName(String destinationName)
destinationName
- public void setDaemonThreads(boolean value)
value
- If true then threads will be daemon threads.public boolean getDaemonThreads()
public javax.jms.MessageListener getMessageListener()
public int getTransactionTimeout()
public String getUser()
public void setMessageListener(javax.jms.MessageListener listener)
listener
- public void setPassword(String string)
string
- public void setTransactionTimeout(int i)
i
- public void setUser(String string)
string
- public String getMessageSelector()
public void setMessageSelector(String selector)
selector
- public int getPoolSize()
public void setPoolSize(int size)
size
- public javax.jms.ExceptionListener getExceptionListener()
public void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
exceptionListener
- public boolean isNoLocal()
public void setNoLocal(boolean noLocal)
noLocal
- public String getSubscriberName()
public void setSubscriberName(String subscriberName)
subscriberName
- protected boolean getNoLocal()
public void start() throws javax.jms.JMSException
javax.jms.JMSException
public void stop()
public boolean getNotifyListenerOnClose()
public void setNotifyListenerOnClose(boolean b)
b
- If true, then the listener will receive a null message if the
pool is closed.public void setUnsubscribeOnClose(boolean b)
b
- If true, then unsubscribe will be done at closing time. This only applies to
durable subscribers (i.e., cases where subscriberName is set).public boolean getUnsubscribeOnClose()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |