Interface Saga<T>

All Superinterfaces:
org.axonframework.eventhandling.EventMessageHandler, org.axonframework.messaging.MessageHandler<org.axonframework.eventhandling.EventMessage<?>>
All Known Implementing Classes:
AnnotatedSaga

public interface Saga<T> extends org.axonframework.eventhandling.EventMessageHandler
Interface describing an implementation of a Saga. Sagas are instances that handle events and may possibly produce new commands or have other side effects. Typically, Sagas are used to manage long running business transactions.

Multiple instances of a single type of Saga may exist. In that case, each Saga will be managing a different transaction. Sagas need to be associated with concepts in order to receive specific events. These associations are managed through AssociationValues. For example, to associate a saga with an Order with ID 1234, this saga needs an association value with key "orderId" and value "1234".

Since:
0.7
Author:
Allard Buijze
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    execute(Consumer<T> invocation)
    Execute the given invocation against the root object of this Saga instance.
    Returns a view on the Association Values for this saga instance.
    Returns the unique identifier of this saga.
    <R> R
    invoke(Function<T,R> invocation)
    Execute the given invocation against the root object of this Saga instance.
    boolean
    Indicates whether or not this saga is active.
    default void
     
    default void
    prepareReset(Object resetContext)
     
    default boolean
     

    Methods inherited from interface org.axonframework.eventhandling.EventMessageHandler

    handle

    Methods inherited from interface org.axonframework.messaging.MessageHandler

    canHandle, canHandleType, getTargetType
  • Method Details

    • getSagaIdentifier

      String getSagaIdentifier()
      Returns the unique identifier of this saga.
      Returns:
      the unique identifier of this saga
    • getAssociationValues

      AssociationValues getAssociationValues()
      Returns a view on the Association Values for this saga instance. The returned instance is mutable.
      Returns:
      a view on the Association Values for this saga instance
    • invoke

      <R> R invoke(Function<T,R> invocation)
      Execute the given invocation against the root object of this Saga instance.
      Type Parameters:
      R - The type of return value expected
      Parameters:
      invocation - the function to invoke. The root object of the Saga is input to the function, the result is the result of the execution.
      Returns:
      The result of the invocation on the Saga.
    • execute

      void execute(Consumer<T> invocation)
      Execute the given invocation against the root object of this Saga instance.
      Parameters:
      invocation - the function to invoke. The root object of the Saga is input to the function.
    • isActive

      boolean isActive()
      Indicates whether or not this saga is active. A Saga is active when its life cycle has not been ended.
      Returns:
      true if this saga is active, false otherwise.
    • supportsReset

      default boolean supportsReset()
      Specified by:
      supportsReset in interface org.axonframework.eventhandling.EventMessageHandler
    • prepareReset

      default void prepareReset()
      Specified by:
      prepareReset in interface org.axonframework.eventhandling.EventMessageHandler
    • prepareReset

      default void prepareReset(Object resetContext)
      Specified by:
      prepareReset in interface org.axonframework.eventhandling.EventMessageHandler