Flow Manager: the saga orchestrator of Mia-Platform

Mia-Platform Team February 3 2021

One of the reasons that could inhibit the adoption of the Saga Pattern approach - about which you can learn more in this article - is the additional effort caused by the need to implement the resulting system, as there are almost no libraries and ready-to-use components for this purpose.

For this reason, in Mia-Platform we decided to implement a generic component that could act as an orchestrator and could be configured in a simple and intuitive way, according to the specific project.

The solution we have chosen consists of a microservice that manages the sagas following the flow imposed by an event-driven finite-state machine, in which the transitions are triggered by messages. These messages are events exchanged asynchronously via an event bus (e.g. Kafka).

Mia-Platform_Saga-Pattern

Mia-Platform makes this component available on its platform as an easily deployable and configurable saga orchestrator, fully integrated with the other features of the platform.

Using the Mia-Platform Flow Manager allows you to configure the saga in a few simple steps. In this way it is possible to save time compared to developing a customized solution; moreover, it offers considerable advantages in terms of business logic management, debugging, and flexibility, in the event of evolution or changes in requirements.

 

The central orchestrator was developed as a platform’s standard service

The advantages are immediately evident. To meet the specific project needs it is sufficient to define the finite state diagram that describes the possible flows of interactions and translate it into a simple configuration file.

Furthermore, it is possible to obtain a simple and clean solution: the entire business logic is concentrated not only in the code of a single service - an intrinsic advantage of the orchestrator approach - but even in a single file.

Using a ready-to-configure and ready-to-release component allowed us to significantly save time on the project. Developing a microservice from scratch that manages communication with the other components, carries on the flow of the saga, and guarantees the necessary robustness has a considerable cost: an extra two months, according to our estimates.

Besides saving resources during development, another advantage that emerged during the UAT was the flexibility of the system in case of changes in requirements.

With our approach, if the business specifications vary, once the actors involved have been prepared, changing the flow only involves a few changes and adaptations, that are:

  • editing the isolated logic of the service/services involved;

  • editing the orchestrator’s configuration file. 

Also, in the event of a single change to the flow, which doesn’t impact the logic, it may be sufficient to change the configuration file, without modifying the code.

Therefore, this avoids having to modify the orchestrator code, recompose the pre-existing flow, apply the change and explicitly manage the aspects of communication with the other services: operations that would have been necessary if we used an ad-hoc implemented orchestrator to manage the specific flow.

For example, if you wanted to add a phase in the saga - let's say the verification of user data - the classic approach would require to modify the code, check where to insert this new step, and modify the entire flow.

Otherwise, with the approach proposed in Mia-Platform, once the actors involved in the change have been prepared, it is sufficient to change a configuration file by adding the new step.

This approach proposes a simplification of the required modification interventions, with a considerable time and resources saving.

 

Is configuring our saga easy?

With the Flow Manager, everything you need to orchestrate the saga is: 

  • Adding the flow-manager plugin:

Mia-Platform_Flow-manager

 

  • Describing  the flow in the appropriate config map file:

 

Mia-Platform_Flow-manager2

 

If you want to know more about the Flow Manager, you can consult our official documentation and you will discover how to configure the json file of the finite-state automaton. 

 

Conclusions

With the gradual abandonment of the monolithic approach and the transition to the world of microservices, sometimes chaotic, the need to maintain control and visibility over everything that happens is becoming more and more pressing.

At Mia-Platform we have addressed this issue also in the context of data updating, data consistency in distributed systems, and full management - even in the event of errors. We discovered and used the Saga Pattern as an optimal solution to manage this problem and enrich the platform.

The article was written by Francesco Francomano, Senior Full Stack Developer, and Giuseppe Manzi, Full Stack Specialist. 

 

New call-to-action

Related Posts

API Management: what cannot be missed in a modern platform

Application Programming Interfaces (APIs) are now the core of software engineering as means to efficiently connect services and appli...

Mia-Platform v6.0 now Generally Available!

Keeping up with our commitment to continuously improve and deliver better software, today we are delighted to announce the release of...
Mia-Platform Team September 16 2020

Legacy Systems Modernization with Mia-Platform

In an Enterprise context, there are “inherited” legacy systems and obsolete solutions from another technological age or resulting fro...
Mia-Platform Team September 23 2020