Monday, October 2, 2017

Blocking vs. non-blocking Flows

Microsoft Flow has many triggers and one of the most useful ones is the HTTP request trigger, where an external party can call a specified endpoint with a message which will trigger the workflow. Basically this feature has two modes, one where the workflow executes logic and returns the outcome and the other where it does not need to return the outcome.

If you have an application which is translating text and you want the text back to the application you can create a Flow similar to the one below. A request which takes a string as input, the text is then translated to Norwegian, and returned at the end.

image

When running a REST query against the Flow URL using for example PowerShell we get the expected result back.

> $json = '{"thetext":"This is a test"}'
> Invoke-RestMethod -Method Post -Uri $uri -Body $json -ContentType "application/json"
dette er en test

This above operation is a blocking one. If you however want the translated text to be sent out as an e-mail, you remove the Response action and add an e-mail action.

image

When you now call the Flow URL you will immediately get a 200 success back, while the workflow executes the steps you have added. A non-blocking workflow.

Summary

If you want to use Microsoft Flow as an API in your application with input and output you can include both a Request and Response step. The calling application will then wait until a response is returned (or it times out). If you however want to use Microsoft Flow to execute an fire and forget action, omit the Response step, and the workflow will start executing while your calling application immediately can continue, regardless of what happens in the workflow.

No comments:

Post a Comment