org.apache.commons.messagelet
Class XAConsumerThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.commons.messagelet.ConsumerThread
          extended by org.apache.commons.messagelet.XAConsumerThread
All Implemented Interfaces:
Runnable

public class XAConsumerThread
extends ConsumerThread

XAConsumerThread is a thread which will perform XA processing of messages

Version:
$Revision: 155459 $
Author:
damon.hamacha, James Strachan

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
XAConsumerThread()
           
 
Method Summary
protected  void cancelTransaction()
          Strategy method to represent the code required to cancel a transaction.
protected  void commitTransaction()
          Strategy method to represent the code required to commit a transaction.
protected  TransactionManager createTransactionManager()
          Factory method to create a TransactionManager via some mechanism.
protected  void delist(Transaction transaction, int flag)
          Delists any resources from the current transaction.
protected  void enlist(Transaction transaction)
          Enlists any resources with the current transaction.
 TransactionManager getTransactionManager()
           
protected  XACapable getXACapable(Messenger messenger)
           
protected  void rollbackTransaction()
          Strategy method to represent the code required to rollback a transaction.
 void setTransactionManager(TransactionManager transctionManager)
          Sets the transaction manager to be used
protected  void startTransaction()
          Strategy method to represent the code required to start a transaction.
 
Methods inherited from class org.apache.commons.messagelet.ConsumerThread
createConsumer, getConsumer, getDestination, getListener, getMessenger, getSelector, isShouldStop, processMessage, rollbackTransaction, run, setDestination, setListener, setMessenger, setSelector, setShouldStop, startConsumer, stopConsumer
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XAConsumerThread

public XAConsumerThread()
Method Detail

getTransactionManager

public TransactionManager getTransactionManager()
                                         throws SystemException
Returns:
the TransactionManager to be used
Throws:
SystemException

setTransactionManager

public void setTransactionManager(TransactionManager transctionManager)
Sets the transaction manager to be used

Parameters:
transctionManager - the transaction manager to be used

createTransactionManager

protected TransactionManager createTransactionManager()
                                               throws SystemException
Factory method to create a TransactionManager via some mechanism. By default this mechanism will lookup in JNDI

Throws:
SystemException

enlist

protected void enlist(Transaction transaction)
               throws Exception
Enlists any resources with the current transaction. Typically the input Messenger's Session will always be enlisted. Then if the current MessageListener implements XACapable then any of its resources will also be enlisted.

Parameters:
transaction - the transaction to enlist resources with
Throws:
Exception - if the enlistment fails for whatever reason

delist

protected void delist(Transaction transaction,
                      int flag)
               throws Exception
Delists any resources from the current transaction. This includes the current input Messenger's Session as well as any resources used by the MessageListener if it implements XACapable

Parameters:
transaction -
flag - is the flag used by JTA when delisting resources. It is either XAResource.TMSUCCESS, XAResource.TMSUSPEND, or XAResource.TMFAIL
Throws:
Exception

startTransaction

protected void startTransaction()
                         throws Exception
Strategy method to represent the code required to start a transaction.

Overrides:
startTransaction in class ConsumerThread
Throws:
Exception

commitTransaction

protected void commitTransaction()
                          throws Exception
Strategy method to represent the code required to commit a transaction.

Overrides:
commitTransaction in class ConsumerThread
Throws:
Exception

rollbackTransaction

protected void rollbackTransaction()
                            throws Exception
Strategy method to represent the code required to rollback a transaction.

Throws:
Exception

cancelTransaction

protected void cancelTransaction()
                          throws Exception
Strategy method to represent the code required to cancel a transaction. This is called when a message is not received.

Overrides:
cancelTransaction in class ConsumerThread
Throws:
Exception

getXACapable

protected XACapable getXACapable(Messenger messenger)
Returns:
an XACapable for the given Messenger


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