Class TransactionContextManager
java.lang.Object
org.springframework.transaction.reactive.TransactionContextManager
Delegate to register and obtain transactional contexts.
Typically used by components that intercept or orchestrate transactional flows such as AOP interceptors or transactional operators.
- Since:
- 5.2
- Author:
- Mark Paluch
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Function<reactor.util.context.Context, reactor.util.context.Context> Create aTransactionContextand register it in the subscriberContext.static reactor.core.publisher.Mono<TransactionContext> Obtain the currentTransactionContextfrom the subscriber context or the transactional context holder.static Function<reactor.util.context.Context, reactor.util.context.Context> Return aFunctionto create or associate a newTransactionContext.static Function<reactor.util.context.Context, reactor.util.context.Context> Return aFunctionto create or associate a newTransactionContextHolder.
-
Method Details
-
currentContext
Obtain the currentTransactionContextfrom the subscriber context or the transactional context holder. Context retrieval fails with NoTransactionException if no context or context holder is registered.- Returns:
- the current
TransactionContext - Throws:
NoTransactionException- if no TransactionContext was found in the subscriber context or no context found in a holder
-
createTransactionContext
public static Function<reactor.util.context.Context, reactor.util.context.Context> createTransactionContext()Create aTransactionContextand register it in the subscriberContext.- Returns:
- functional context registration.
- Throws:
IllegalStateException- if a transaction context is already associated.- See Also:
-
getOrCreateContext
public static Function<reactor.util.context.Context, reactor.util.context.Context> getOrCreateContext()Return aFunctionto create or associate a newTransactionContext. Interaction with transactional resources throughTransactionSynchronizationManagerrequires a TransactionContext to be registered in the subscriber context.- Returns:
- functional context registration.
-
getOrCreateContextHolder
public static Function<reactor.util.context.Context, reactor.util.context.Context> getOrCreateContextHolder()Return aFunctionto create or associate a newTransactionContextHolder. Creation and release of transactions within a reactive flow requires a mutable holder that follows a top to down execution scheme. Reactor's subscriber context follows a down to top approach regarding mutation visibility.- Returns:
- functional context registration.
-