Interface SagaModel<T>

Type Parameters:
T - The saga type

public interface SagaModel<T>
Interface of a model that describes a Saga of type T. Use the SagaModel to obtain associations and event handlers for the Saga.
  • Method Details

    • resolveAssociation

      Optional<AssociationValue> resolveAssociation(EventMessage eventMessage, ProcessingContext context)
      Returns the AssociationValue used to find sagas of type T that can handle the given eventMessage. If the saga type does not handle events of this type an empty Optional is returned.
      Parameters:
      eventMessage - The event to find the association value for.
      context - The ProcessingContext in which the event is being processed.
      Returns:
      Optional of the AssociationValue for the event, or an empty Optional if the saga doesn't handle the event
    • findHandlerMethods

      List<MessageHandlingMember<? super T>> findHandlerMethods(EventMessage event, ProcessingContext context)
      Returns a List of MessageHandlingMember that can handle the given event.
      Parameters:
      event - The EventMessage to be handled.
      context - The ProcessingContext in which the event is being processed.
      Returns:
      Event message handlers for the given event.
    • hasHandlerMethod

      default boolean hasHandlerMethod(EventMessage eventMessage, ProcessingContext context)
      Indicates whether the Saga described by this model has a handler for the given eventMessage
      Parameters:
      eventMessage - The message to check the availability of a handler for.
      context - The ProcessingContext in which the event is being processed.
      Returns:
      true if there the Saga has a handler for this message, otherwise false.
    • modelFactory

      SagaMetaModelFactory modelFactory()
      Returns the factory that created this model.
      Returns:
      The factory that made this model
    • supportedEvents

      Set<QualifiedName> supportedEvents()
      Returns the QualifiedNames of all events supported by the Saga described by this model, that is, the events for which the Saga declares a @SagaEventHandler method.
      Returns:
      the QualifiedNames of all events supported by the Saga described by this model
    • payloadTypeFor

      Optional<Class<?>> payloadTypeFor(QualifiedName eventName)
      Returns the payload type of the handler that is declared for events with the given eventName.

      Sagas resolve handlers and association values from the payload's runtime type. An event read from an event store carries a serialized payload, which has to be converted to this type first.

      Parameters:
      eventName - the qualified name of the event
      Returns:
      the handler's payload type, or empty if no handler is declared for the given name