public interface Transaction
Provides the transaction boundary while accessing a channel.
A Transaction instance is used to encompass channel access via the following idiom:
 Channel ch = ...
 Transaction tx = ch.getTransaction();
 try {
   tx.begin();
   ...
   // ch.put(event) or ch.take()
   ...
   tx.commit();
 } catch (ChannelException ex) {
   tx.rollback();
   ...
 } finally {
   tx.close();
 }
 
 Depending upon the implementation of the channel, the transaction semantics may be strong, or best-effort only.
 Transactions must be thread safe. To provide  a guarantee of thread safe
 access to Transactions, see BasicChannelSemantics and
 BasicTransactionSemantics.
Channel| Modifier and Type | Interface and Description | 
|---|---|
static class  | 
Transaction.TransactionState  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
begin()
Starts a transaction boundary for the current channel operation. 
 | 
void | 
close()
Ends a transaction boundary for the current channel operation. 
 | 
void | 
commit()
Indicates that the transaction can be successfully committed. 
 | 
void | 
rollback()
Indicates that the transaction can must be aborted. 
 | 
void begin()
Starts a transaction boundary for the current channel operation. If a transaction is already in progress, this method will join that transaction using reference counting.
Note: For every invocation of this method there must be a corresponding invocation of close() method. Failure to ensure this can lead to dangling transactions and unpredictable results.
void commit()
void rollback()
void close()
Ends a transaction boundary for the current channel operation. If a transaction is already in progress, this method will join that transaction using reference counting. The transaction is completed only if there are no more references left for this transaction.
Note: For every invocation of this method there must be a corresponding invocation of begin() method. Failure to ensure this can lead to dangling transactions and unpredictable results.
Copyright © 2009-2022 Apache Software Foundation. All Rights Reserved.