Annotation Interface Saga


@Target({TYPE,ANNOTATION_TYPE}) @Retention(RUNTIME) @Component @Scope("prototype") public @interface Saga
Annotation that informs Axon's auto configurer for Spring that a given Component is a saga instance.

Requires the axon-legacy module on the classpath, which carries the Saga itself. The Saga is registered on an event processor named after the Saga type, <SagaName>Processor, unless a @Namespace on the Saga or an explicit EventProcessorDefinition says otherwise. That processor is configured through the regular axon.eventhandling.processors.<SagaName>Processor properties. Sagas take part in the same processor assignment pass as ordinary event handlers, so a Saga and an ordinary handler resolving to the same processor name share that processor, as they did under one @ProcessingGroup in Axon Framework 4.

The stereotype only lets Spring discover the type; Axon owns the lifecycle of Saga instances. Spring collaborators are resolved as parameters of a @SagaEventHandler method, not injected into Saga fields. A Saga type must therefore be public and expose an accessible no-argument constructor.

Sagas carry the Axon Framework 4 API, to ease migration of projects that cannot move off it in one go. This annotation keeps its Axon Framework 4 package for that reason, so migrating Saga classes component-scan unchanged.

Since:
3.0
Author:
Allard Buijze
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Selects the name of the SagaStore bean.
  • Element Details

    • sagaStore

      String sagaStore
      Selects the name of the SagaStore bean. If left empty the saga will be stored in the Saga Store configured in the global Axon Configuration.
      Returns:
      the name of the SagaStore bean to keep Sagas of this type in
      Default:
      ""