public interface TransactionalOperator
The central method is transactional(reactor.core.publisher.Flux<T>)
, supporting transactional wrapping
of functional sequences code that. This operator handles the transaction lifecycle
and possible exceptions such that neither the ReactiveTransactionCallback
implementation nor the calling code needs to explicitly handle transactions.
Typical usage: Allows for writing low-level data access objects that use resources such as database connections but are not transaction-aware themselves. Instead, they can implicitly participate in transactions handled by higher-level application services utilizing this class, making calls to the low-level services via an inner-class callback object.
Note: Transactional Publishers should avoid Subscription cancellation. See the Cancel Signals section of the Spring Framework reference for more details.
execute(org.springframework.transaction.reactive.TransactionCallback<T>)
,
ReactiveTransactionManager
Modifier and Type | Method and Description |
---|---|
static TransactionalOperator |
create(ReactiveTransactionManager transactionManager)
Create a new
TransactionalOperator using ReactiveTransactionManager ,
using a default transaction. |
static TransactionalOperator |
create(ReactiveTransactionManager transactionManager,
TransactionDefinition transactionDefinition)
|
<T> reactor.core.publisher.Flux<T> |
execute(TransactionCallback<T> action)
Execute the action specified by the given callback object within a transaction.
|
default <T> reactor.core.publisher.Flux<T> |
transactional(reactor.core.publisher.Flux<T> flux)
Wrap the functional sequence specified by the given Flux within a transaction.
|
<T> reactor.core.publisher.Mono<T> |
transactional(reactor.core.publisher.Mono<T> mono)
Wrap the functional sequence specified by the given Mono within a transaction.
|
default <T> reactor.core.publisher.Flux<T> transactional(reactor.core.publisher.Flux<T> flux)
flux
- the Flux that should be executed within the transactionnull
if noneTransactionException
- in case of initialization, rollback, or system errorsRuntimeException
- if thrown by the TransactionCallback<T> reactor.core.publisher.Mono<T> transactional(reactor.core.publisher.Mono<T> mono)
mono
- the Mono that should be executed within the transactionTransactionException
- in case of initialization, rollback, or system errorsRuntimeException
- if thrown by the TransactionCallback<T> reactor.core.publisher.Flux<T> execute(TransactionCallback<T> action) throws TransactionException
Allows for returning a result object created within the transaction, that is, a domain object or a collection of domain objects. A RuntimeException thrown by the callback is treated as a fatal exception that enforces a rollback. Such an exception gets propagated to the caller of the template.
action
- the callback object that specifies the transactional actionTransactionException
- in case of initialization, rollback, or system errorsRuntimeException
- if thrown by the TransactionCallbackstatic TransactionalOperator create(ReactiveTransactionManager transactionManager)
TransactionalOperator
using ReactiveTransactionManager
,
using a default transaction.transactionManager
- the transaction management strategy to be usedstatic TransactionalOperator create(ReactiveTransactionManager transactionManager, TransactionDefinition transactionDefinition)
transactionManager
- the transaction management strategy to be usedtransactionDefinition
- the transaction definition to apply