top of page
  • Writer's pictureMarcel Haas

Microsoft Flow / State Machine / Worker Flows (4/8)

Updated: Jan 29, 2019


Think of "Worker Flows" as small, dedicated Flows, executing specific process steps or activities. Kind of like a function in grown-up software development.

 

As all state logic is managed by the Controller, the main idea of a Worker Flow is to encapsulate actions and groups of actions into small, stateless subprocesses. A example could be an approval process activity, which is carried out in a Worker Flow and reporting the approval result back to the controller. Or a process step which interacts with an ERP or CRM system. Workers get called by the controller with a work task order and do stuff. They report their activities and process step outcome back to the controller, which maintains overall state and initializes next process steps with the modified state. So, basically Worker Flows are the only state modifying entity in this very elegant solution design.

Microsoft Flow - State Machine - State Object Transfer

Stateless because the state is managed in a JSON message object, which we store in an Azure Storage Queue and pass from the controller to the worker and back. The worker picks the message from the queue, then parses and processes the content with the work tasks. So we mostly creat short running Flows and allows us easily to overcome some of the general challenges in Flow design.

 

Sample Implementation

Beauty often lies in simplicity. So, let's see how it's done. As you can see based on the sample implementation, this Flow has a very clear and easy to read and understand structure and is scalable in all dimensions.

Please read the implementation guide for detailed reference on the whole implementation of a State Machine Pattern in Flow:


 

Trigger (State Input)

  • Azure Queue Storage


A Worker Flow is triggered if a new message (JSON Object) is added to an Azure Storage Queue "worker-process". The object can be added by any web-client, capable of talking rest.

 

Connector

The Worker Flow in it's basic implementation, only needs the following connector:


  • Azure Queue Storage

 

Actions

We actually don't need a lot to make this pattern work in Flow. These are the actions involved for a minimal operation state:


  • Variables

  • Switches

  • Conditions

  • Add Message to Storage Queue

  • Delete Message from Storage Queue

 

Content Index

There is a lot more content available to you:


170 views0 comments
bottom of page