Top Description Methods
org.springframework.transaction

public Interface ReactiveTransactionManager

extends TransactionManager
Known Direct Implementers
org.springframework.transaction.reactive.AbstractReactiveTransactionManager
Imports
reactor.core.publisher.Mono, org.springframework.lang.Nullable

This is the central interface in Spring's reactive transaction infrastructure. Applications can use this directly, but it is not primarily meant as an API: Typically, applications will work with either transactional operators or declarative transaction demarcation through AOP.
Authors
Mark Paluch, Juergen Hoeller
Since
5.2
See Also
org.springframework.transaction.reactive.TransactionalOperator, org.springframework.transaction.interceptor.TransactionInterceptor, org.springframework.transaction.PlatformTransactionManager, ConfigurableTransactionManager

Method Summary

Modifier and TypeMethod and Description
public Mono<Void>
commit(ReactiveTransaction
object returned by the getTransaction method
transaction
)

Commit the given transaction, with regard to its status.

public Mono<ReactiveTransaction>

Returns:

transaction status object representing the new or current transaction
getReactiveTransaction
(TransactionDefinition
the TransactionDefinition instance, describing propagation behavior, isolation level, timeout etc.
definition
)

Emit a currently active reactive transaction or create a new one, according to the specified propagation behavior.

public Mono<Void>
rollback(ReactiveTransaction
object returned by the getTransaction method
transaction
)

Perform a rollback of the given transaction.

Method Detail

commitback to summary
public Mono<Void> commit(ReactiveTransaction transaction)

Commit the given transaction, with regard to its status. If the transaction has been marked rollback-only programmatically, perform a rollback.

If the transaction wasn't a new one, omit the commit for proper participation in the surrounding transaction. If a previous transaction has been suspended to be able to create a new one, resume the previous transaction after committing the new one.

Note that when the commit call completes, no matter if normally or propagating an exception, the transaction must be fully completed and cleaned up. No rollback call should be expected in such a case.

Note

In contrast to PlatformTransactionManager, exceptions are propagated through the reactive pipeline returned from this method. Also, depending on the transaction manager implementation, commit may propagate org.springframework.dao.DataAccessException as well.

Parameters
transaction:ReactiveTransaction

object returned by the getTransaction method

Exceptions
UnexpectedRollbackException:
in case of an unexpected rollback that the transaction coordinator initiated
HeuristicCompletionException:
in case of a transaction failure caused by a heuristic decision on the side of the transaction coordinator
TransactionSystemException:
in case of commit or system errors (typically caused by fundamental resource failures)
IllegalTransactionStateException:
if the given transaction is already completed (that is, committed or rolled back)
See Also
ReactiveTransaction#setRollbackOnly
getReactiveTransactionback to summary
public Mono<ReactiveTransaction> getReactiveTransaction(TransactionDefinition definition)

Emit a currently active reactive transaction or create a new one, according to the specified propagation behavior.

Note that parameters like isolation level or timeout will only be applied to new transactions, and thus be ignored when participating in active ones.

Furthermore, not all transaction definition settings will be supported by every transaction manager: A proper transaction manager implementation should throw an exception when unsupported settings are encountered.

An exception to the above rule is the read-only flag, which should be ignored if no explicit read-only mode is supported. Essentially, the read-only flag is just a hint for potential optimization.

Note

In contrast to PlatformTransactionManager, exceptions are propagated through the reactive pipeline returned from this method.

Parameters
definition:TransactionDefinition

the TransactionDefinition instance, describing propagation behavior, isolation level, timeout etc.

Returns:Mono<ReactiveTransaction>

transaction status object representing the new or current transaction

Exceptions
TransactionException:
in case of lookup, creation, or system errors
IllegalTransactionStateException:
if the given transaction definition cannot be executed (for example, if a currently active transaction is in conflict with the specified propagation behavior)
See Also
TransactionDefinition#getPropagationBehavior, TransactionDefinition#getIsolationLevel, TransactionDefinition#getTimeout, TransactionDefinition#isReadOnly
rollbackback to summary
public Mono<Void> rollback(ReactiveTransaction transaction)

Perform a rollback of the given transaction.

If the transaction wasn't a new one, just set it rollback-only for proper participation in the surrounding transaction. If a previous transaction has been suspended to be able to create a new one, resume the previous transaction after rolling back the new one.

Do not call rollback on a transaction if commit failed. The transaction will already have been completed and cleaned up when commit returns, even in case of a commit exception. Consequently, a rollback call after commit failure will lead to an IllegalTransactionStateException.

Note

In contrast to PlatformTransactionManager, exceptions are propagated through the reactive pipeline returned from this method. Also, depending on the transaction manager implementation, rollback may propagate org.springframework.dao.DataAccessException as well.

Parameters
transaction:ReactiveTransaction

object returned by the getTransaction method

Exceptions
TransactionSystemException:
in case of rollback or system errors (typically caused by fundamental resource failures)
IllegalTransactionStateException:
if the given transaction is already completed (that is, committed or rolled back)