Package org.apache.pulsar.client.api.v5
Interface Transaction
public interface Transaction
A Pulsar transaction handle.
Transactions provide exactly-once semantics across multiple topics and subscriptions. Messages produced and acknowledgments made within a transaction are atomically committed or aborted.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Abort this transaction, discarding all produced messages and rolling back acknowledgments.async()Return an asynchronous view of this transaction.voidcommit()Commit this transaction, making all produced messages visible and all acknowledgments durable.state()The current state of this transaction.
-
Method Details
-
commit
Commit this transaction, making all produced messages visible and all acknowledgments durable.- Throws:
PulsarClientException- if the transaction cannot be committed (e.g., it has already been aborted, timed out, or encountered an error)
-
abort
Abort this transaction, discarding all produced messages and rolling back acknowledgments.- Throws:
PulsarClientException- if the transaction cannot be aborted (e.g., it has already been committed or encountered an error)
-
async
AsyncTransaction async()Return an asynchronous view of this transaction.- Returns:
- the
AsyncTransactioncounterpart of this transaction
-
state
Transaction.State state()The current state of this transaction.- Returns:
- the current
Transaction.Stateof this transaction
-