Modelling Saga Services

Saga Pattern Role

For Service Projects of type Java Spring Boot where the extension Saga Pattern Support is enabled, each Domain Service can be either be marked as a Saga Orchestrator or as Saga Participant during creation of a service. These basic settings can be changed at any time in the service overview.

Saga Orchestrator services are representing the starting point of a Saga. They are responsible to trigger the execution of the participants in the correct saga context.

Tip:

If your Saga is spread across multiple microservices, every microservice needs to have at least one Orchestrator service in it.

For a service marked as a Saga Orchestrator the following input fields are needed:

  • On Compensate Method: If set to true automatically an onCompensate method will be generated.
  • On Complete Method: If set to true automatically an onComplete method will be generated.
  • Propagation Level: required, requires_new, mandatory, supports, not_supported, never
  • Completion mode: auto or manual
  • Participants: You can associate participants by using the Add action. All services of the project that are marked as Saga Participant are shown and can be associated. To remove the association you can either deselect or use the row action Remove.

Saga Participant services contain the actual execution logic of the steps within a Saga and are associated to an Orchestrator.

For a service marked as a Saga Participant the following input fields are needed:

  • On Compensate Method: If set to true automatically an onCompensate method will be generated.
  • On Complete Method: If set to true automatically an onComplete method will be generated.
  • Propagation Level: required, requires_new, mandatory, supports, not_supported, never
  • Completion mode: auto or manual
  • Options Expressions: Key-value pair used to define additional context for the Saga. They are sent by the coordinator, when compensating or completing. The value can be expressed in the camel expression language. For more information see also Apache Camel Saga EIP Options
Note:

Please consider, that Saga Participants need to have the same input entity modeled as the Saga Orchestrators to which they are associated. The input will automatically be passed from the orchestrator to its participants.

Note:

A Saga participant has no output. If an output is already defined for the service, it will be deleted.

Warning:

Please note that changing the "Saga Pattern Role" field afterwards can break already implemented code!