activemq::core::ActiveMQTransaction Class Reference

#include <ActiveMQTransaction.h>

Inheritance diagram for activemq::core::ActiveMQTransaction:

activemq::concurrent::TaskListener activemq::connector::TransactionInfo activemq::core::ActiveMQSessionResource activemq::connector::ConnectorResource List of all members.

Public Member Functions

 ActiveMQTransaction (ActiveMQConnection *connection, ActiveMQSession *session, const util::Properties &properties)
virtual ~ActiveMQTransaction (void)
virtual void addToTransaction (ActiveMQMessage *message, ActiveMQMessageListener *listener)
virtual void removeFromTransaction (ActiveMQMessageListener *listener)
virtual void commit (void) throw ( exceptions::ActiveMQException )
virtual void rollback (void) throw ( exceptions::ActiveMQException )
virtual connector::TransactionInfogetTransactionInfo (void) const
virtual unsigned int getTransactionId (void) const
virtual void setTransactionId (const unsigned int id)
virtual const connector::SessionInfogetSessionInfo (void) const
virtual void setSessionInfo (const connector::SessionInfo *session)
virtual connector::ConnectorResourcegetConnectorResource (void)

Protected Member Functions

virtual void onTaskComplete (concurrent::Runnable *task)
virtual void onTaskException (concurrent::Runnable *task, exceptions::ActiveMQException &ex)
virtual void clearTransaction (void)

Private Types

typedef std::list< ActiveMQMessage * > MessageList
typedef std::map< ActiveMQMessageListener *,
MessageList
RollbackMap

Private Attributes

ActiveMQConnectionconnection
ActiveMQSessionsession
connector::TransactionInfotransactionInfo
RollbackMap rollbackMap
concurrent::Mutex rollbackLock
int maxRedeliveries
int redeliveryDelay
concurrent::Mutex tasksDone
int taskCount

Classes

class  RollbackTask

Detailed Description

Transaction Management class, hold messages that are to be redelivered upon a request to rollback. The Tranasction represents an always running transaction, when it is committed or rolled back it silently creates a new transaction for the next set of messages. The only way to permanently end this tranaction is to delete it.

Configuration options

transaction.redeliveryDelay Wait time between the redelivery of each message

transaction.maxRedeliveryCount Max number of times a message can be redelivered, if the session is rolled back more than this many time, the message is dropped.


Member Typedef Documentation

typedef std::list< ActiveMQMessage* > activemq::core::ActiveMQTransaction::MessageList [private]
 

typedef std::map< ActiveMQMessageListener*, MessageList > activemq::core::ActiveMQTransaction::RollbackMap [private]
 


Constructor & Destructor Documentation

ActiveMQTransaction::ActiveMQTransaction ActiveMQConnection connection,
ActiveMQSession session,
const util::Properties properties
 

Constructor

Parameters:
connection - Connection to the Broker
session - the session that contains this transaction
properties - configuratoin parameters for this object

ActiveMQTransaction::~ActiveMQTransaction void   )  [virtual]
 


Member Function Documentation

void ActiveMQTransaction::addToTransaction ActiveMQMessage message,
ActiveMQMessageListener listener
[virtual]
 

Adds the Message as a part of the Transaction for the specified ActiveMQConsumer.

Parameters:
message - Message to Transact
listener - Listener to redeliver to on Rollback

void ActiveMQTransaction::clearTransaction void   )  [protected, virtual]
 

Clean out all Messages from the Rollback Map, deleting the messages as it goes. Destroys the Transaction Info object as well.

Exceptions:
ActiveMQException 

void ActiveMQTransaction::commit void   )  throw ( exceptions::ActiveMQException ) [virtual]
 

Commit the current Transaction

Exceptions:
CMSException 

virtual connector::ConnectorResource* activemq::core::ActiveMQTransaction::getConnectorResource void   )  [inline, virtual]
 

Retrieve the Connector resource that is associated with this Session resource.

Returns:
pointer to a Connector Resource, can be NULL

Implements activemq::core::ActiveMQSessionResource.

virtual const connector::SessionInfo* activemq::core::ActiveMQTransaction::getSessionInfo void   )  const [inline, virtual]
 

Gets the Session Info that this transaction is attached too

Returns:
SessionnInfo pointer

Implements activemq::connector::TransactionInfo.

virtual unsigned int activemq::core::ActiveMQTransaction::getTransactionId void   )  const [inline, virtual]
 

Gets the Transction Id

Returns:
unsigned int Id

Implements activemq::connector::TransactionInfo.

virtual connector::TransactionInfo* activemq::core::ActiveMQTransaction::getTransactionInfo void   )  const [inline, virtual]
 

Get the Transaction Information object for the current Transaction, returns NULL if no transaction is running

Returns:
TransactionInfo

void ActiveMQTransaction::onTaskComplete concurrent::Runnable task  )  [protected, virtual]
 

Called when a queued task has completed, the task that finished is passed along for user consumption. The task is deleted and the count of outstanding tasks is reduced.

Parameters:
task - Runnable Pointer to the task that finished

Implements activemq::concurrent::TaskListener.

void ActiveMQTransaction::onTaskException concurrent::Runnable task,
exceptions::ActiveMQException ex
[protected, virtual]
 

Called when a queued task has thrown an exception while being run. The Callee should assume that this was an unrecoverable exeption and that this task is now defunct. Deletes the Task and notifies the connection that the exception has occurred. Reduce the outstanding task count.

Parameters:
task - Runnable Pointer to the task
ex - The ActiveMQException that was thrown.

Implements activemq::concurrent::TaskListener.

void ActiveMQTransaction::removeFromTransaction ActiveMQMessageListener listener  )  [virtual]
 

Removes the ActiveMQMessageListener and all of its transacted messages from the Transaction, this is usually only done when a ActiveMQMessageListener is destroyed.

Parameters:
listener - consumer who is to be removed.

void ActiveMQTransaction::rollback void   )  throw ( exceptions::ActiveMQException ) [virtual]
 

Rollback the current Transaction

Exceptions:
CMSException 

virtual void activemq::core::ActiveMQTransaction::setSessionInfo const connector::SessionInfo session  )  [inline, virtual]
 

Gets the Session Info that this transaction is attached too

Parameters:
session - SessionnInfo pointer

Implements activemq::connector::TransactionInfo.

virtual void activemq::core::ActiveMQTransaction::setTransactionId const unsigned int  id  )  [inline, virtual]
 

Sets the Transction Id

Parameters:
id - unsigned int Id

Implements activemq::connector::TransactionInfo.


Member Data Documentation

ActiveMQConnection* activemq::core::ActiveMQTransaction::connection [private]
 

int activemq::core::ActiveMQTransaction::maxRedeliveries [private]
 

int activemq::core::ActiveMQTransaction::redeliveryDelay [private]
 

concurrent::Mutex activemq::core::ActiveMQTransaction::rollbackLock [private]
 

RollbackMap activemq::core::ActiveMQTransaction::rollbackMap [private]
 

ActiveMQSession* activemq::core::ActiveMQTransaction::session [private]
 

int activemq::core::ActiveMQTransaction::taskCount [private]
 

concurrent::Mutex activemq::core::ActiveMQTransaction::tasksDone [private]
 

connector::TransactionInfo* activemq::core::ActiveMQTransaction::transactionInfo [private]
 


The documentation for this class was generated from the following files:
Generated on Thu Aug 3 18:03:32 2006 for activemq-cpp by  doxygen 1.4.5