Package com.microsoft.azure.servicebus
Class TransactionContext
- java.lang.Object
-
- com.microsoft.azure.servicebus.TransactionContext
-
public class TransactionContext extends Object
Represents an active servicebus transaction. A transaction is initiated by callingMessagingFactory.startTransactionAsync(). A transaction can result in commit or rollback. To commit, callMessagingFactory.endTransactionAsync(TransactionContext, boolean)withcommit = trueTo rollback, callMessagingFactory.endTransactionAsync(TransactionContext, boolean)withcommit = false
-
-
Field Summary
Fields Modifier and Type Field Description static TransactionContextNULL_TXN
-
Constructor Summary
Constructors Constructor Description TransactionContext(ByteBuffer txnId, MessagingFactory messagingFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit()Commits the transactionCompletableFuture<Void>commitAsync()Asynchronously commits the transactionByteBuffergetTransactionId()Represents the service-side transactionIDvoidnotifyTransactionCompletion(boolean commit)This is not to be called by the user.voidrollback()Rollback the transactionCompletableFuture<Void>rollbackAsync()Asynchronously rollback the transaction.StringtoString()
-
-
-
Field Detail
-
NULL_TXN
public static TransactionContext NULL_TXN
-
-
Constructor Detail
-
TransactionContext
public TransactionContext(ByteBuffer txnId, MessagingFactory messagingFactory)
-
-
Method Detail
-
getTransactionId
public ByteBuffer getTransactionId()
Represents the service-side transactionID- Returns:
- transaction ID
-
commit
public void commit() throws ServiceBusException, InterruptedExceptionCommits the transaction- Throws:
ServiceBusException- if Commit failedInterruptedException- if the current thread was interrupted while waiting
-
commitAsync
public CompletableFuture<Void> commitAsync()
Asynchronously commits the transaction- Returns:
- a CompletableFuture for the commit operation
-
rollback
public void rollback() throws ServiceBusException, InterruptedExceptionRollback the transaction- Throws:
ServiceBusException- if rollback failedInterruptedException- if the current thread was interrupted while waiting
-
rollbackAsync
public CompletableFuture<Void> rollbackAsync()
Asynchronously rollback the transaction.- Returns:
- a CompletableFuture for the rollback operation
-
notifyTransactionCompletion
public void notifyTransactionCompletion(boolean commit)
This is not to be called by the user.- Parameters:
commit- true indicates success and false for rollback
-
-