Use workflows to orchestrate flow services across runtimes with webMethods.io Integration

products: webMethods.io Integration

Introduction

webMethods.io Integration workflows can seamlessly execute flow services across your hybrid integration landscape. In this how-to, learn how to use webMethods.io workflows to orchestrate flow services across edge runtimes from one centralized control plane.

This is the sixth part of a series of webMethods.io Integration tutorials exploring the platform’s Super iPaaS Develop anywhere, deploy anywhere capabilities. If you missed the previous part, you can find it here: Create and develop flow services to run on the Cloud Runtime with webMethods.io Integration.

Prefer watching a video? See our Developer Evangelist Theo Ezell walk through the steps in this video tutorial:
:film_projector: Use workflows to orchestrate flow services across runtimes with webMethods.io Integration

Pre-requisite

A webMethods.io Integration environment.

Note: These capabilities are not available by default. Contact your sales representative for more information.

Let’s begin

For the purposes of this tutorial, we will use two Flow services created in the same project in a webMethods.io Integration environment.

The first Flow service getEmployeeById uses a JDBC Adapter to retrieve an employee record from a database and run on a remote Edge Runtime.

On the other hand, the isInteger service runs on the default Cloud Runtime and validates if an input string is an integer or not. If you need a refresher on how to create Flow services that run on the default Cloud Runtime, please refer to Create and develop flow services to run on the Cloud Runtime with webMethods.io Integration.

The workflow we will create executes both services and sends an alert email in case of failure.

Navigate to the Workflows tab and click the plus icon to create a new one:

Choose the option to create the workflow from scratch:

Type a workflow name, for example getEmployee and click Done:

Set up a trigger action

Click the gear icon of the start step, this will open the triggers list. Since this workflow will be called by a webhook, choose the Webhook trigger:

Clicking Next leads to the Configure webhook payload data which will be used as sample data to configure the rest of the workflow:

Copy the test webhook URL and paste it into an API platform for building and using APIs, for example Postman. Make sure to provide the sample data in a JSON format in the API request body – in our case the Employee ID {“employeeId”:”7”} and send it:

Go back to the webhook configuration in the webMethods.io Integration environment and click Fetch to retrieve the data:

You should see the fetched Headers and Body data. Click Next.

The next step is to choose an authentication method for your API request. In our case, we will use a webhook key – enable the webhook key button, click Generate token and copy it.

Clicking Next will generate your webhook URL. Copy it and paste it into Postman.

Under the Headers tab, add a webhook_key key and paste your webhook key generated earlier as value:

Configure the execution of a Flow service

Let’s move on to the next step of the workflow. Navigate to the Flow services tab on the Connectors list and drag and drop the isInteger Flow service to the canvas. This should automatically connect it to the trigger step:

Click the gear icon to configure it. Since it is a Flow Anywhere service, you should select the Runtime on which the service will run. In this case, this will be the Default Cloud runtime:

Click Next. Now map the employeeID string received from the webhook trigger to the inString string and click Next again:

Then click on Test to capture the output data and Done.

Set up Switch cases

Next, we will use the Switch tool to perform a check whether the isInteger service returns true or false. Navigate to the Utility tab on the Connectors list, search for the Switch tool under the Developers tools, and drag and drop it to the canvas. This should automatically connect it to the previous step.

To set the first Switch case, drag and drop to the canvas the getEmployeeById Flow service:

Click the gear icon on the Case 1 arrow, add condition and check if the isInteger output matches true:

Now continue with the configuration of the getEmployeeById Flow service by clicking its gear icon. This service will run on a remote Edge Runtime – search it in the dropdown menu and click Next:

Map the employeeId string with the employeeId webhook output string, Click Next, then Test and Done.

For the second Switch case or the Error case, drag and drop close to the Switch tool the Gmail connector:

Click the gear icon on the Case 2 arrow, add a condition, and check if the isInteger output matches false:

Now continue with the configuration of the Gmail connector by clicking its gear icon. Select Send an Email as action, connect your Gmail account with webMethods.io Integration, and click Next:

Fill out the To field with the email address/es that you want to send this email to, type a Subject line and an Email body content:

Return data step configuration

The last step is to return the API request results. Add to the canvas the Return Data on Sync Webhook tool next to the getEmployeeById Flow service. Click the gear icon and set the positive response data, for example the employeeId and lastName strings:

Add one more Return Data on Sync Webhook tool, this time next to the Gmail connector. Click the gear icon, set the Error message as well as set the status code to 500:

Connect the two Return Data on Sync Webhook steps to the end and save your workflow:

Test the workflow

Now, we are ready to test the workflow. First with valid data – go to your API test platform, type a valid employee ID, for example 9 and click Send:

This will fetch the last name of the employee with ID 9.

For the second case, type an invalid employee ID, for example 9.2 and you should receive a 500 Internal Server Error with your Error message as well as receive an email with the invalid data:

What to do next

Now, you’ve seen how to use a workflow to execute Flow services across multiple Runtimes in your webMethods.io environment. Next, learn how to:

Export and import Flow services with webMethods.io Integration

Useful links | Relevant resources

2 Likes