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:](emoji.discourse-cdn.com/twitter/film_projec.. ":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.

[Flow services tab](global.discourse-cdn.com/techcommunity/orig.. "Flow services tab")

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

[Create new workflow](global.discourse-cdn.com/techcommunity/orig.. "Create new workflow")

Choose the option to create the workflow from scratch:

[Workflow from sratch](global.discourse-cdn.com/techcommunity/orig.. "Workflow from sratch")

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

[Name the workflow](global.discourse-cdn.com/techcommunity/orig.. "Name the workflow")

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:

[Webhook trigger](global.discourse-cdn.com/techcommunity/orig.. "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:

[Webhook configuration](global.discourse-cdn.com/techcommunity/orig.. "Webhook configuration")

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:

[Run sample data](global.discourse-cdn.com/techcommunity/orig.. "Run sample data")

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

[Fetch sample data](global.discourse-cdn.com/techcommunity/orig.. "Fetch sample 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.

[Authentication method](global.discourse-cdn.com/techcommunity/orig.. "Authentication method")

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

[Webhook URL](global.discourse-cdn.com/techcommunity/orig.. "Webhook URL")

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

[API endpoint and webhook key](global.discourse-cdn.com/techcommunity/orig.. "API endpoint and webhook key")

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:

[Add Flow service](global.discourse-cdn.com/techcommunity/orig.. "Add Flow service")

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:

[Configure isInteger](global.discourse-cdn.com/techcommunity/orig.. "Configure isInteger")

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

[Configure isInteger 2](global.discourse-cdn.com/techcommunity/orig.. "Configure isInteger 2")

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:

[Switch case 1](global.discourse-cdn.com/techcommunity/orig.. "Switch case 1")

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

[Configure case 1](global.discourse-cdn.com/techcommunity/orig.. "Configure case 1")

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:

[Configure getEmployeeById](global.discourse-cdn.com/techcommunity/orig.. "Configure getEmployeeById")

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

[Configure getEmployeeById 2](global.discourse-cdn.com/techcommunity/orig.. "Configure getEmployeeById 2")

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

[Switch case 2](global.discourse-cdn.com/techcommunity/orig.. "Switch case 2")

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

[Configure case 2](global.discourse-cdn.com/techcommunity/orig.. "Configure case 2")

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:

[Configure Gmail action](global.discourse-cdn.com/techcommunity/orig.. "Configure Gmail action")

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:

[Configure Gmail connector](global.discourse-cdn.com/techcommunity/orig.. "Configure Gmail connector")

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:

[Configure Return Data on Sync 1](global.discourse-cdn.com/techcommunity/orig.. "Configure Return Data on Sync 1")

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:

[Configure Return Data on Sync 2](global.discourse-cdn.com/techcommunity/orig.. "Configure Return Data on Sync 2")

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

[Final workflow](global.discourse-cdn.com/techcommunity/orig.. "Final 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:

[Test with valid data](global.discourse-cdn.com/techcommunity/orig.. "Test with valid data")

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:

[Test with invalid data](global.discourse-cdn.com/techcommunity/orig.. "Test with 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

Read full topic