Event Store
Event-store is the location that StackSaga stores the data Relevant to the transaction execution as well as the storing the metadata of the components that you provided like aggregator details, executor details, application version details etc. all the data you can see through the StackSaga Admin dashboard. You can configure the database for the event-store as the pattern of database per service.
Otherwise, you can provide one event-store for all services. But as the best practice, event-store per service is recommended. You can define a separate schema for event-store by providing the configurations.
-
One Event-Store Per Service.
-
One Common Event-Store For All Services.
The requirement of the event-store
StackSaga framework provides the SEC capabilities. Then the framework has to store each execution data (aggregator state and the transaction information like that each sub transaction was failed or success, etc.) The interesting part is how the framework saves each state of the whole transaction process. As the initial step, the transaction is saved in the event store with initial data that you provided with the relevant aggregator. After the saving the INIT step, the first executor is invoked and after invoking the executor, the framework saves the new updated aggregator state in the event store. Likewise, after all and every steps the updated aggregator state and the execution state are saved in the event-store.
What are the reasons for saving the states in the event-store?
-
To retry purpose.
Any kind of execution can retry if the execution is failed due to a retryable-exception like network exception. Because if an execution is failed due to a network error, it is not fair that it is treated as an exception in the microservice architecture. Because one transaction consists of multiple individual transactions and any time one service may have gone down. Therefore, retrying the execution is one of the main features that StackSaga provides. StackSaga always considers the eventual consistency.
-
To see each and every step and their changes by using the StackSaga Admin Dashboard.
You can see how the aggregator was changed while each sub process of the transaction which transactions were failed or which transaction is pending to the execution and which transaction has been successfully done, etc.