Sagas
Sometimes called a Process Manager
In the Cronus framework, Sagas—also known as Process Managers—are designed to handle complex workflows that span multiple aggregates. They provide a centralized mechanism to coordinate and manage long-running business processes, ensuring consistency and reliability across the system.
Key Characteristics of Sagas
Event-Driven Coordination: Sagas listen for domain events, which represent business changes that have already occurred, and react accordingly to drive the process forward.
State Management: Unlike simple event handlers, Sagas maintain state to track the progress of the workflow, enabling them to handle complex scenarios and ensure that all steps are completed successfully.
Command Dispatching: Sagas can send new commands to aggregates or other components, orchestrating the necessary actions to achieve the desired business outcome.
When to Use Sagas
Sagas are particularly useful when dealing with processes that:
Involve multiple aggregates or bounded contexts.
Require coordination of several steps or actions.
Need to handle compensating actions in case of failures to maintain consistency.
By encapsulating the workflow logic within a Saga, developers can manage complex business processes more effectively, ensuring that all parts of the system work together harmoniously.
Communication Guide Table
Event
Domain events represent business changes that have already happened.
Best Practices
A Saga can send new commands to drive the process forward.
Ensure that Sagas are idempotent to handle potential duplicate events gracefully.
Maintain clear boundaries for each Saga to prevent unintended side effects.
Saga example
Last updated
Was this helpful?