Flow Manager
The Flow Manager is a saga orchestrator, capable to manage flows structured by using the Architectural pattern named Saga Pattern using, in particular, the Command/Orchestration approach.
Checkout the Flow Manager Configurator: a tool to easily generate the configuration file of the service.
Introduction
The Flow Manager receives a Finite State Machine through a configuration file and is capable to orchestrate the saga flow based on the received machine.
To handle the flow it needs other "actors", or, services that listen the Flow Manager commands and reply with events (later will be explained the commands/events approach) through a common channel, usually a Message Broker.
Let's explain with an example of a well-known flow, the e-commerce one.
The following schema contains a simple commerce finite state machine (for simplicity, error flows are omitted):
The Flow Manager, with this Finite State Machine, can orchestrate the saga flow through the states above, working like in the following image (the Flow Manager is the Order Saga Orchestrator):
As you can see in the flow above, every step is managed by the Flow Manager, named Order Saga Orchestrator in the example above, so the flow could be the following:
- the user creates the order
- the Order Service forwards a creation request to the Flow Manager
- the Flow Manager sends the
executePayment
command to the Message Broker - the Payment Service, unknown to the Flow Manager, handles the command and replies with a
paymentExecuted
event - the Flow Manager listens the
paymentExecuted
event, handles it and replies with theprepareOrder
command - the Stock Service handles the command and replies with a
orderPrepared
event - the Flow Manager listens the
orderPrepared
, handles it and replies with thedeliverOrder
command - the Delivery Service handles the command and replies with a
orderDelivered
event - the flow is complete
As in the example above, the Flow Manager is the core of the Saga, contains all the business logic and orchestrates the flow.
More of the information above are about the Saga Pattern, Command/Orchestration approach, go ahead into the documentation to know the details about the Flow Manager.
Simple Flow Manager based architecture
To make the Flow Manager architecture clearer, following some diagram of a "Flow Manager based" microservices architecture.
In the example there are the following components (microservices):
- flow-manager: the Flow Manager microservice
- persistency-manager: the Persistency Manager microservice (see the dedicated documentation here)
- order-service: a sample microservice that starts the saga
- microservice-n: some microservice that collaborate to continue the saga
The architecture above is simply feasible with the Console, as showed in the following image:
Following two architectures diagrams, based on different communication protocols (see the dedicated documentation here):
Flow Manager architecture with message broker
Flow Manager architecture with REST protocol
Horizontal scaling
Kafka approach
Using the Kafka approach allows the service to horizontal scale because the messages are processed sequentially and, moreover, the kafka message key is the ID of the saga, and is unique → grants the messages order because messages are in the same topic partition.
The maximum number of replicas is limited by the maximum number of the kafka topics partitions.
Further details
Follow the pages below for more about the Flow Manager: