Class 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.

Since:
5.2
Author:
Mark Paluch
See Also:
  • Method Details

    • currentContext

      public static reactor.core.publisher.Mono<TransactionContext> currentContext()
      Obtain the current TransactionContext from 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 a TransactionContext and register it in the subscriber Context.
      Returns:
      functional context registration.
      Throws:
      IllegalStateException - if a transaction context is already associated.
      See Also:
      • Mono.contextWrite(Function)
      • Flux.contextWrite(Function)
    • getOrCreateContext

      public static Function<reactor.util.context.Context,reactor.util.context.Context> getOrCreateContext()
      Return a Function to create or associate a new TransactionContext. Interaction with transactional resources through TransactionSynchronizationManager requires 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 a Function to create or associate a new TransactionContextHolder. 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.