Package org.apache.qpid.server.txn
Class LocalTransaction
- java.lang.Object
-
- org.apache.qpid.server.txn.LocalTransaction
-
- All Implemented Interfaces:
ServerTransaction
public class LocalTransaction extends Object implements ServerTransaction
A concrete implementation of ServerTransaction where enqueue/dequeue operations share a single long-lived transaction. The caller is responsible for invoking commit() (or rollback()) as necessary.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LocalTransaction.ActivityTimeAccessor
static interface
LocalTransaction.LocalTransactionListener
-
Nested classes/interfaces inherited from interface org.apache.qpid.server.txn.ServerTransaction
ServerTransaction.Action, ServerTransaction.EnqueueAction
-
-
Constructor Summary
Constructors Constructor Description LocalTransaction(MessageStore transactionLog)
LocalTransaction(MessageStore transactionLog, LocalTransaction.ActivityTimeAccessor activityTime, TransactionObserver transactionObserver, boolean resetable)
LocalTransaction(MessageStore transactionLog, TransactionObserver transactionObserver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPostTransactionAction(ServerTransaction.Action postTransactionAction)
Register an Action for execution after transaction commit or rollback.void
addTransactionListener(LocalTransaction.LocalTransactionListener listener)
void
commit()
Commit the transaction represented by this object.void
commit(Runnable immediateAction)
void
commitAsync(Runnable deferred)
void
dequeue(Collection<MessageInstance> queueEntries, ServerTransaction.Action postTransactionAction)
Dequeue a message(s) from queue(s) registering a post transaction action.void
dequeue(MessageEnqueueRecord record, ServerTransaction.Action postTransactionAction)
Dequeue a message from a queue registering a post transaction action.void
enqueue(Collection<? extends BaseQueue> queues, EnqueueableMessage message, ServerTransaction.EnqueueAction postTransactionAction)
Enqueue a message(s) to queue(s) registering a post transaction action.void
enqueue(TransactionLogResource queue, EnqueueableMessage message, ServerTransaction.EnqueueAction postTransactionAction)
Enqueue a message to a queue registering a post transaction action.long
getTransactionStartTime()
Return the time the current transaction started.long
getTransactionUpdateTime()
Return the time of the last activity on the current transaction.boolean
hasOutstandingWork()
boolean
isDischarged()
boolean
isRollbackOnly()
boolean
isTransactional()
void
removeTransactionListener(LocalTransaction.LocalTransactionListener listener)
void
rollback()
Rollback the transaction represented by this object.boolean
setRollbackOnly()
void
sync()
-
-
-
Constructor Detail
-
LocalTransaction
public LocalTransaction(MessageStore transactionLog)
-
LocalTransaction
public LocalTransaction(MessageStore transactionLog, TransactionObserver transactionObserver)
-
LocalTransaction
public LocalTransaction(MessageStore transactionLog, LocalTransaction.ActivityTimeAccessor activityTime, TransactionObserver transactionObserver, boolean resetable)
-
-
Method Detail
-
getTransactionStartTime
public long getTransactionStartTime()
Description copied from interface:ServerTransaction
Return the time the current transaction started.- Specified by:
getTransactionStartTime
in interfaceServerTransaction
- Returns:
- the time this transaction started or 0 if not in a transaction
-
getTransactionUpdateTime
public long getTransactionUpdateTime()
Description copied from interface:ServerTransaction
Return the time of the last activity on the current transaction.- Specified by:
getTransactionUpdateTime
in interfaceServerTransaction
- Returns:
- the time of the last activity or 0 if not in a transaction
-
addPostTransactionAction
public void addPostTransactionAction(ServerTransaction.Action postTransactionAction)
Description copied from interface:ServerTransaction
Register an Action for execution after transaction commit or rollback. Actions will be executed in the order in which they are registered.- Specified by:
addPostTransactionAction
in interfaceServerTransaction
-
dequeue
public void dequeue(MessageEnqueueRecord record, ServerTransaction.Action postTransactionAction)
Description copied from interface:ServerTransaction
Dequeue a message from a queue registering a post transaction action. A store operation will result only for a if the record is not null.- Specified by:
dequeue
in interfaceServerTransaction
-
dequeue
public void dequeue(Collection<MessageInstance> queueEntries, ServerTransaction.Action postTransactionAction)
Description copied from interface:ServerTransaction
Dequeue a message(s) from queue(s) registering a post transaction action. Store operations will result only for a persistent messages on durable queues.- Specified by:
dequeue
in interfaceServerTransaction
-
enqueue
public void enqueue(TransactionLogResource queue, EnqueueableMessage message, ServerTransaction.EnqueueAction postTransactionAction)
Description copied from interface:ServerTransaction
Enqueue a message to a queue registering a post transaction action. A store operation will result only for a persistent message on a durable queue.- Specified by:
enqueue
in interfaceServerTransaction
-
enqueue
public void enqueue(Collection<? extends BaseQueue> queues, EnqueueableMessage message, ServerTransaction.EnqueueAction postTransactionAction)
Description copied from interface:ServerTransaction
Enqueue a message(s) to queue(s) registering a post transaction action. Store operations will result only for a persistent messages on durable queues.- Specified by:
enqueue
in interfaceServerTransaction
-
commit
public void commit()
Description copied from interface:ServerTransaction
Commit the transaction represented by this object. If the caller has registered one or more Actions, the postCommit() method on each will be executed immediately after the underlying transaction has committed.- Specified by:
commit
in interfaceServerTransaction
-
commit
public void commit(Runnable immediateAction)
- Specified by:
commit
in interfaceServerTransaction
-
commitAsync
public void commitAsync(Runnable deferred)
-
rollback
public void rollback()
Description copied from interface:ServerTransaction
Rollback the transaction represented by this object. If the caller has registered one or more Actions, the onRollback() method on each will be executed immediately after the underlying transaction has rolled-back.- Specified by:
rollback
in interfaceServerTransaction
-
sync
public void sync()
-
isTransactional
public boolean isTransactional()
- Specified by:
isTransactional
in interfaceServerTransaction
-
setRollbackOnly
public boolean setRollbackOnly()
-
isRollbackOnly
public boolean isRollbackOnly()
-
hasOutstandingWork
public boolean hasOutstandingWork()
-
isDischarged
public boolean isDischarged()
-
addTransactionListener
public void addTransactionListener(LocalTransaction.LocalTransactionListener listener)
-
removeTransactionListener
public void removeTransactionListener(LocalTransaction.LocalTransactionListener listener)
-
-