Microservices Workflow

Published on: Jan 02, 2023

Microservices Workflow Optimizing Application Architecture 

Microservice architecture offers several architectural solutions. It addressed current inefficiencies ranging from the hosting of infrastructure to the modularization of applications. In doing so, it finds new challenges that need solutions.  

Managing lengthy transactions involving several microservices is one of the most critical concerns. These may be a component of synchronous or asynchronous workflows, and long-running transactions can either include manual chores or be entirely automated. In conclusion, large environments must have a defined design approach and technological underpinning for how microservices cooperate. If not, it produces antipatterns. 

These include: 

  • If no organization is established, the microservices will call each other without supervision, resulting in a large clump of difficult-to-trace invocations. 
  • The ESB orchestration antipattern is recreated if just one microservice is used as the orchestrator. 
  • When combining an event-driven architecture with the saga pattern, it becomes more challenging to track down and fix problems after the second event. 

A design pattern that organizes lengthy transactions involving several microservices is known as the “Microservices workflow.” This design pattern sits in the middle between choreography and orchestration. It has an orchestration workflow, and the entity keeps track of business flow by calling the defined tasks. 

The invocations of the tasks are made via events (using Kafka), which are Request Events. So, they are simultaneously separated from the orchestration process. Microservice workflow adheres to a workflow design pattern known as “outbound context,” characterized by the workflow’s lack of business data in the execution pipeline. Microservices handle the activity by subscribing to the events, taking action by issuing a “respond” event, and then returning control of the workflow. 

The only duties that the workflow must do are starting activities and monitoring their completion. When creating an action, the payload just contains the workflow instance id and a signaling event that the microservice has received. After the activities are finished, the workflow does not get data from the microservices since the response events do not provide business data. 

In this approach, the processes for microservices prevent functional entanglement between microservices. An “activity-microservice” is started by a workflow. The microservices need data to do the work and gather the data needed to finish the activity independently, which may be accomplished in various ways. Using the properties of Kafka stream joins is one of the most stunning and effective methods to deal with the retrieval of data (from the outbound context). 

As a SQL-like join condition, it generates a new event if additional events are present. For instance, if two distinct events occur and can be correlated, the stream join creates a new event with the payload of the two original ones. The stream join event produced from the workflow signaling event and another event containing the necessary payload data will then be consumed by the microservices.