Class AbstractReactiveTransactionManager

java.lang.Object
org.springframework.transaction.reactive.AbstractReactiveTransactionManager
All Implemented Interfaces:
Serializable, ReactiveTransactionManager, TransactionManager
Direct Known Subclasses:
R2dbcTransactionManager

public abstract class AbstractReactiveTransactionManager extends Object implements ReactiveTransactionManager, Serializable
Abstract base class that implements Spring's standard reactive transaction workflow, serving as basis for concrete platform transaction managers.

This base class provides the following workflow handling:

  • determines if there is an existing transaction;
  • applies the appropriate propagation behavior;
  • suspends and resumes transactions if necessary;
  • checks the rollback-only flag on commit;
  • applies the appropriate modification on rollback (actual rollback or setting rollback-only);
  • triggers registered synchronization callbacks.

Subclasses have to implement specific template methods for specific states of a transaction, e.g.: begin, suspend, resume, commit, rollback. The most important of them are abstract and must be provided by a concrete implementation; for the rest, defaults are provided, so overriding is optional.

Transaction synchronization is a generic mechanism for registering callbacks that get invoked at transaction completion time. This is mainly used internally by the data access support classes for R2DBC, MongoDB, etc. The same mechanism can also be leveraged for custom synchronization needs in an application.

The state of this class is serializable, to allow for serializing the transaction strategy along with proxies that carry a transaction interceptor. It is up to subclasses if they wish to make their state to be serializable too. They should implement the java.io.Serializable marker interface in that case, and potentially a private readObject() method (according to Java serialization rules) if they need to restore any transient state.

Since:
5.2
Author:
Mark Paluch, Juergen Hoeller
See Also: