In an event driven architecture using choreogeaphy model, how do we keep current, global state of the process?
Lets say we have a process where many services p1,...,pn
transition many states s1,...,sn
.
States order is important and state s3
cannot happen after state s4
.
The only way I can think of is a state machine implemented as a part of the system that keeps the global state and that state machine would prevent state s4
to be written if we are already in s5
.
Is there any better way to solve this?
(I do not want orchestration)
PS. this is only for some states where parts of the process can happen in parallel. For example, queue beimg processed by 2 different consumers that run in parallel.
Since this is a more general question I am only able to give a more general answer:
Because in an event-driven system, processes are split into multiple event handlers, event-driven design results in stack ripping.
I believe the first mention of stack ripping is in Cooperative Task Management without Manual Stack Management. The authors identify that "for each routine that is ripped, the programmer will have to manually manage procedural language features that are normally handled by a compiler".
So whatever your solution, you have to manage the application state on an application level. Explicitly maintaining a state machine (centralized design) is certainly a popular choice.