Package com.yworkflow

Interface WorkflowTransaction


public interface WorkflowTransaction
Provides transactional support for workflow operations. The WorkflowTransaction interface allows workflow operations to be executed within a transaction context, ensuring atomicity and consistency.

Transactions ensure that either all operations within the transaction succeed, or all operations are rolled back if any operation fails. This is particularly important for workflow operations that involve multiple state changes or external system interactions.

The interface supports both operations that return a value and operations that return void. All operations are executed within the same transaction context.

Since:
1.0
See Also:
  • Method Details

    • execute

      <R, T extends Throwable> R execute(WorkflowTransactionalOperation<R,T> operation) throws T
      Executes a transactional operation that returns a value. The operation is executed within a transaction context, and the transaction is committed if the operation completes successfully, or rolled back if an exception is thrown.
      Type Parameters:
      R - the return type of the operation
      T - the type of exception that can be thrown
      Parameters:
      operation - the operation to execute
      Returns:
      the result of the operation
      Throws:
      T - if the operation throws an exception
    • execute

      <T extends Throwable> void execute(WorkflowTransactionalVoidOperation<T> operation) throws T
      Executes a transactional operation that returns void. The operation is executed within a transaction context, and the transaction is committed if the operation completes successfully, or rolled back if an exception is thrown.
      Type Parameters:
      T - the type of exception that can be thrown
      Parameters:
      operation - the operation to execute
      Throws:
      T - if the operation throws an exception
    • noOp

      static WorkflowTransaction noOp()
      Returns:
      a noop WorkflowTransaction that simply execute the passed operations