TransactionContext Class

  • java.lang.Object
    • com.microsoft.azure.servicebus.TransactionContext

public class TransactionContext

Represents an active servicebus transaction. A transaction is initiated by calling startTransactionAsync(). A transaction can result in commit or rollback. To commit, call endTransactionAsync(TransactionContext transaction, boolean commit) with To rollback, call endTransactionAsync(TransactionContext transaction, boolean commit) with

Field Summary

Modifier and Type Field and Description
TransactionContext NULL_TXN

Constructor Summary

Constructor Description
TransactionContext(ByteBuffer txnId, MessagingFactory messagingFactory)

Method Summary

Modifier and Type Method and Description
void commit()

Commits the transaction

CompletableFuture<Void> commitAsync()

Asynchronously commits the transaction

ByteBuffer getTransactionId()

Represents the service-side transactionID

void notifyTransactionCompletion(boolean commit)

This is not to be called by the user.

void rollback()

Rollback the transaction

CompletableFuture<Void> rollbackAsync()

Asynchronously rollback the transaction.

String toString()

Field Details

NULL_TXN

public static TransactionContext NULL_TXN= new TransactionContext(null, null)

Constructor Details

TransactionContext

public TransactionContext(ByteBuffer txnId, MessagingFactory messagingFactory)

Parameters:

txnId
messagingFactory

Method Details

commit

public void commit()

Commits the transaction

Throws:

ServiceBusException - if Commit failed
InterruptedException - if the current thread was interrupted while waiting

commitAsync

public CompletableFuture commitAsync()

Asynchronously commits the transaction

Returns:

a CompletableFuture for the commit operation

getTransactionId

public ByteBuffer getTransactionId()

Represents the service-side transactionID

Returns:

transaction ID

notifyTransactionCompletion

public void notifyTransactionCompletion(boolean commit)

This is not to be called by the user.

Parameters:

commit - true indicates success and false for rollback

rollback

public void rollback()

Rollback the transaction

Throws:

ServiceBusException - if rollback failed
InterruptedException - if the current thread was interrupted while waiting

rollbackAsync

public CompletableFuture rollbackAsync()

Asynchronously rollback the transaction.

Returns:

a CompletableFuture for the rollback operation

toString

public String toString()

Applies to