Learn how to use IBM® App Connect on IBM Cloud™ (with a plan that provides enterprise capabilities) to construct an integration that can aggregate, sequence, and process events that are based on an event-driven architecture.


You want to construct an integration that provides an API that generates the rate at which different types of clothes are sold. Rates for two different clothing types will be produced: jumpers and pants. The current sales number for each clothing type can be retrieved by using two different APIs, which will respond with the total current sales of each type. The integration will need to complete the following actions:

  1. Call the jumpers and pants APIs to get the current sales numbers.
  2. Pause for five seconds.
  3. Make the same calls again to get the new sales numbers.
  4. Combine the responses for the original requests and the delayed requests to calculate a sales rate for each of the two clothing types.
  5. Return the combined sales rate information back to the original caller of the integration.

The integration will complete all the actions that it can in parallel and asynchronously by using these App Connect nodes: Timeout, Aggregation, Resequence, and Collector. This tutorial shows how these event-driven nodes can be used to fulfill a complex integration pattern. In most cases, you won’t need to use all of these nodes in one integration, but they are all included here to illustrate the strengths of each type of node.

The integration can also be extended to aggregate more than two different clothing types. For example, the details from 10 or 20 different systems could be easily aggregated without any major changes to the integration.

First, find or create everything you need:

Import the enterprise integration project into App Connect Enterprise or IBM Integration Bus, and examine the message flow:

You must complete this step because the deployed integrations will need to be modified to access a dummy sales system that also needs to be deployed to App Connect.

All the resources required for this tutorial are provided in a project interchange file named appconnect_eda_tutorial_pi.zip.

The steps are the same for App Connect Enterprise V11 Toolkit and IBM Integration Bus V10 Toolkit (the toolkit):

  1. Download the project interchange file by clicking the link above and saving the file to a local directory.
  2. Open the toolkit.
  3. To import the project into the toolkit, click File > Import, expand IBM Integration, select Project Interchange, and click Next. Then browse to select the downloaded project interchange file and click Finish.

Two new projects called SalesSystem and Sample_Sales_Rate are displayed in the toolkit.

The SalesSystem project is a simple REST API integration, which is designed to be the back end for a dummy sales system. It is written as an integration rather than a web application purely to make it simple to set up the tutorial without the need to create a web application.

The second project, Sample_Sales_Rate, contains the actual integration for the tutorial and implements an event-driven flow that uses event-driven nodes to fulfill the requirements in our given scenario. This project consists of a REST API that provides a single GET operation, which triggers the flow to make various calls to the sales system to calculate the current rate of sale of jumpers and pants:

As shown above, there is a single resource path for the REST service:

  • /rate: Retrieves the current sales rate of jumpers and pants

The resource path has a single GET operation that returns the current rate at which jumpers and pants are selling. The integration has to make a complex combination of REST calls to calculate the rate with the aid of timeouts, aggregation, collection, and sequencing. The basic steps are as follows:

  1. A REST call is made to the integration flow to get the rates for jumpers and pants.
  2. The integration calls a REST API to get the current number of jumpers sold and, in parallel, makes a REST API call to get the number of pants sold.
  3. After a five-second wait, the integration repeats the process.
  4. After responses are returned for all of the REST calls, the integration calculates the sales rate for jumpers and pants in the last five seconds.
  5. The integration then returns a JSON document with the current rates for jumpers and pants.

Let’s look at the Sample_Sales_Rate subflow, which is called getRate.subflow, in detail.

The main parts of the flow are as follows:

  • [1]: The first part of the flow uses timeout nodes to set up two events to drive the sampling of the number of jumpers and pants sold. A Timeout Control node is used to specify an event to trigger immediately and then to trigger again in five seconds. The events trigger the delivery of an event to the Timeout Notification node, which then executes the logic to retrieve and aggregate the requests.
  • [2]: The second part of the flow makes the REST requests and then aggregates the responses returned by the two REST calls into a single event, which can then be re-sequenced and collected. As well as aggregating out the requests to the two APIs, this part of the flow also echos back the original request to help maintain context about the original calling application.
  • [3]: The Timeout Notification node triggers the aggregation part of the flow twice. So, the third part of the flow uses a Resequence node to keep the two sets of aggregation requests in order by using the count number from the timeout notification messages.
  • [4]: Finally, in the fourth part of the flow, the Collector node collects all the ordered aggregation requests and combines them (by performing a calculation using the four collected REST calls) into one rate document that can be returned.

Configure the integration in App Connect on IBM Cloud:

You’ll now use App Connect on IBM Cloud to run the two integration applications:

  • Sample_Sales_Rate, which implements an event-driven flow that uses event-driven nodes
  • SalesSystem, which is a dummy sales system back end that provides the REST APIs that Sample_Sales_Rate requires

You’ll need to deploy SalesSystem first to acquire the route URL, and then subsequently modify Sample_Sales_Rate to call this URL in three places within its flow.

  1. To begin, import the supplied SalesSystem BAR file into App Connect and then start the integration server:
    1. Download the SalesSystem.bar file.
    2. Sign in to App Connect on IBM Cloud.
    3. From the App Connect on IBM Cloud dashboard, click New > Import a BAR file and select the BAR file that you downloaded. Then click Import BAR. The integration server is displayed as a tile in the dashboard.

      Tile for the SalesSystem integration server in the dashboard

    4. Click the tile to view its contents, which include the full URL for the route short name:
    5. Make a note of the full URL for the route short name. (In the example above, it is https://eohtgrba.devtest.ace.ibm.com, but yours might be different.) You’ll use this value later to modify the Sample_Sales_Rate application.
    6. Switch off basic authentication by clicking HTTPS basic authentication settings and then setting Basic authentication to Off:

    7. Return to the dashboard and start the integration server by opening its options menu [⋮] and then clicking Start. When the integration server shows Running, it’s running and ready to use.

      SalesSystem integration server in a Running state

  2. Now that the dummy sales application is running, go back to the toolkit and modify the Sample_Sales_Rate event-driven flow as follows:
    1. Open the getRate.subflow flow in the Sample_Sales_Rate project and locate these nodes:
      • HTTP Get pants
      • HTTP Get jumpers
      • HTTP echo orig

      HTTP nodes in the getRate.subflow flow

    2. Click the HTTP Get pants node and locate the Web service URL field in the Properties tab.

      Then replace the current route with the route short name (in our example, https://eohtgrba.devtest.ace.ibm.com) that you copied earlier from the SalesSystem integration server in App Connect. Leave the rest of the URL unchanged.

      Current route of the HTTP node in the toolkit

      Replaced route of the HTTP node in the toolkit

    3. Repeat the previous step for both the HTTP Get jumpers node and the HTTP echo orig node.
    4. Finally, rebuild the SalesRate.bar file. From the Application Development view in the left pane, expand BARs and double-click the SalesRate.bar entry. In the right pane, click the Prepare tab of the BAR File editor, ensure that the Sample_Sales_Rate check box is selected in the list of REST APIs, and then click Build and Save. (Leave the toolkit open.)

  3. Return to the App Connect dashboard to import and start the rebuilt SalesRate BAR file:
    1. From the App Connect on IBM Cloud dashboard, click New > Import a BAR file and select the SalesRate.bar file from your local “workspace” directory.

      Tip: To obtain the location of the SalesRate.bar file, go to the Application Development view in the toolkit, expand BARs, right-click the SalesRate.bar entry, and click Properties. In the Properties window, the Location value shows the directory where the file is stored.

      Toolkit location of the SalesRate.bar file

    2. After you’ve selected the SalesRate.bar file, click Import BAR.

      "Import a BAR file" panel for a flow with event-driven nodes

      The SalesRate integration server is displayed as a tile in the dashboard.

      Tile for the SalesRate integration server in the dashboard

    3. Start the integration server by opening its options menu [⋮] and then clicking Start. When the integration server shows Running, it’s running and ready to use.

Finally, test your integration:

Now, try calling the REST API to sample the sales rates of jumpers and pants. At this point, you should have these two integration servers running in the App Connect dashboard.

Running integration servers

  1. From the App Connect dashboard, click the SalesRate tile to open the integration server.
  2. Click Show API Explorer.

    Show API Explorer link

  3. To test the getRate operation, click Try it.

    Call operation button for the getRate operation

  4. Click Call operation and success should get returned after about 10 seconds. You should see the sales rates for jumpers and pants in the response.

If all of these steps work, then you have the tutorial up and running. If it fails, an error message with the reason will be returned. Check the integration log for any errors – you can access the log from the integration server in the dashboard.

Join The Discussion

Your email address will not be published. Required fields are marked *