Execution Patterns - Sync & Async
Hi there! In this tutorial we are going to talk about Execution Patterns.
Easyflow provides you the capability to decide how you want your workflow to be executed, synchronously or asynchronously through a feature called “Execution Pattern”.
You can configure the execution pattern at workflow level or even at step level.
Synchronous means that you are expecting to get a response from the workflow in real-time.
Asynchronous is when you want the process to happen behind the scene and not necessarily in real-time.
Let’s take a look at how to do that in Easyflow. For this demonstration, we are going to create two steps, each is a mapper connector.
First step, it’s just a placeholder doing nothing while the second step returns a JSON response with status code 200 and a success message.
By default, Easyflow will configure every step synchronously.
Let’s run the workflow as an endpoint.
By looking at the URL, you can see the parameter async = false. This means the workflow will be executed synchronously, and the workflow returns the same JSON response configured in the second step mapper.
Let’s change the async parameter value to true and call the workflow again. As you can see, the request has been sent to queue and your workflow will be executed behind the scene.
Now, let’s try to configure the execution mode at step level. From the second step, go to the execution pattern section, and choose Queue. Queue means asynchronous mode while transactional means synchronous mode.
Let’s call the workflow again, but this time synchronously by setting up the async = false.
As you can see, the response indicates that 1 request has been sent to the queue to be executed behind the scene.
Thank you for watching this tutorial.
Please feel free to contact us if you have any questions.
Updated on: 04/08/2022