类 TransactionContextManager
- java.lang.Object
- org.springframework.transaction.reactive.TransactionContextManager
public abstract class TransactionContextManager extends Object
Delegate to register and obtain transactional contexts.Typically used by components that intercept or orchestrate transactional flows such as AOP interceptors or transactional operators.
- 从以下版本开始:
- 5.2
- 作者:
- Mark Paluch
- 另请参阅:
TransactionSynchronization
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static Function<reactor.util.context.Context,reactor.util.context.Context>
createTransactionContext()
Create aTransactionContext
and register it in the subscriberContext
.static reactor.core.publisher.Mono<TransactionContext>
currentContext()
Obtain the currentTransactionContext
from the subscriber context or the transactional context holder.static Function<reactor.util.context.Context,reactor.util.context.Context>
getOrCreateContext()
Return aFunction
to create or associate a newTransactionContext
.static Function<reactor.util.context.Context,reactor.util.context.Context>
getOrCreateContextHolder()
Return aFunction
to create or associate a newTransactionContextHolder
.
方法详细资料
currentContext
public static reactor.core.publisher.Mono<TransactionContext> currentContext() throws NoTransactionException
Obtain the currentTransactionContext
from the subscriber context or the transactional context holder. Context retrieval fails with NoTransactionException if no context or context holder is registered.- 返回:
- the current
TransactionContext
- 抛出:
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 aTransactionContext
and register it in the subscriberContext
.- 返回:
- functional context registration.
- 抛出:
IllegalStateException
- if a transaction context is already associated.- 另请参阅:
Mono.subscriberContext(Function)
,Flux.subscriberContext(Function)
getOrCreateContext
public static Function<reactor.util.context.Context,reactor.util.context.Context> getOrCreateContext()
Return aFunction
to create or associate a newTransactionContext
. Interaction with transactional resources throughTransactionSynchronizationManager
requires a TransactionContext to be registered in the subscriber context.- 返回:
- functional context registration.
getOrCreateContextHolder
public static Function<reactor.util.context.Context,reactor.util.context.Context> getOrCreateContextHolder()
Return aFunction
to 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.- 返回:
- functional context registration.