Class ContextPropagationAsyncHandler

java.lang.Object
com.arjuna.ats.jta.cdi.async.ContextPropagationAsyncHandler

public final class ContextPropagationAsyncHandler extends Object
Handling asynchronous context propagation calls. It extends transactions until the intercepted method's async return type is completed.
  • Constructor Details

    • ContextPropagationAsyncHandler

      public ContextPropagationAsyncHandler()
  • Method Details

    • tryHandleAsynchronously

      public static boolean tryHandleAsynchronously(jakarta.transaction.TransactionManager tm, jakarta.transaction.Transaction tx, jakarta.transaction.Transactional transactional, AtomicReference objectToHandleRef, Class<?> returnType, RunnableWithException afterEndTransaction) throws Exception

      Tries to handle asynchronously the returned type from the @Transactional call. This CDI interceptor method checks the return type intercepted method. If it's a asynchronous "type" (objectToHandle is instanceof e.g. CompletionStage) then the transaction completion (committing/roll-backing) will be suspended until the asynchronous code finishes.

      If the interceptor returns nothing or just some "normal" return type then synchronous handling is processed. Synchronous means that the transaction is completed just here when the method annotated with @Transactional ends.

      Parameters:
      tm - transaction manager
      tx - the original transaction
      transactional - link to method which is annotated with @Transactional
      objectToHandleRef - on interceptor proceed this is the returned type which differentiate the action; method changes the object when it was handled asynchronously
      returnType -
      afterEndTransaction - a lamda invocation on transaction finalization
      Returns:
      @{code true} if async handling is possible and it was proceeded, @{code false} means async processing is not possible; the method changes the value referenced by @{code objectToHandleRef}, when @{code true} is returned
      Throws:
      Exception - failure on async processing error happens