Aggregation nodes using RESTAsyncRequest nodes with back-end services

IBM Knowledge Center

Learn how to use the Aggregation nodes to fan-out and fan-in messages using asynchronous REST nodes.

Import projects

When you click Import, three REST APIs will be created in your workspace:

The REST API AggregationRESTAsync provides a single GET operation on a resource named AggregationResponse. The subflow representation of the operation, getAggregatedResponse.subflow, uses RESTAsyncRequest nodes to fan-out two requests. Two RESTAsyncResponse nodes are used to fan-in reply messages from the back-end message flows.

The REST API AggregationRESTBackend1 provides a single GET operation on a resource named Backend1. The subflow representation of the operation, getBackend1.subflow, contains a Mapping node to uppercase the data.

The REST API AggregationRESTBackend2 provides a single GET operation on a resource named Backend2. The subflow representation of the operation, getBackend2.subflow, contains a Mapping node to uppercase the data.

For simplicity, the REST API and two back-end REST APIs can all be deployed to the same integration server. If you wish, you could deploy AggregationRESTBackend1 and AggregationRESTBackend2 to different integration servers (assuming you update the Swagger json files used by the RESTRequest nodes in AggregationRESTAsync).

Once you import the tutorial, the provided REST APIs are ready to be deployed and tested. Before you do this, you need to create the required MQ queues, as described on the Prepare tab.

Create queues

Although this solution uses HTTP to route messages between the REST APIs, the aggregation nodes require MQ queues to operate.

  1. Create the default IBM Integration Bus queues in WebSphere MQ by completing the following steps:
    1. Open the IBM Integration Console.
    2. In the console window, type the following command:
      server\sample\wmq\iib_createqueues qmgr
      where
      qmgr is the queue manager name.
  2. Associate the default integration node with the queue manager by completing the following steps:
    1. In the console window, stop the default integration node by typing the following command:
      mqsistop -i TESTNODE_userid
    2. Associate the queue manager with the default integration node, TESTNODE_userid by typing the following command:
      mqsichangebroker TESTNODE_userid -q qmgr
      where
      qmgr is the queue manager name
    3. Start the default integration node by typing the following command:
      mqsistart TESTNODE_userid

Deploy the back-end REST APIs

  1. Deploy the AggregationRESTBackend1 REST API, by dragging and dropping it on to the default integration server.
  2. Deploy the AggregationRESTBackend2 REST API, by dragging and dropping it on to the default integration server.

Use any web browser to simply test the REST API

  1. Look inside the AggregationRESTAsync REST API, right-click the AggregationRESTAsync.msgflow and select Open with > Message Flow Editor.
    • Click the Flow Exerciser icon to start testing the flow. When it appears, the Ready to record message dialog can be dismissed by clicking Close.
  2. Open any web browser. We will be using this to send an HTTP GET into the REST API AggregationRESTAsync.
    • In the address bar of the browser paste in the URL for the HTTP GET operation. If you have used default settings, then this is likely to be:
    • http://localhost:7080/aggregationrestasync/v1/AggregatedResponse?Field1=value1&Field2=value2
    • Note that this URL includes query parameters with the values value1 and value2. One of these values will be sent to each back-end REST API. The back end REST APIs will uppercase the values and reply.
  3. Return to AggregationRESTAsync.msgflow.
    • Click the View Path icon to see the path which the message took through the flow and see the message content on the path. You can open the subflow getAggregatedResponse.subflow and click on the flow connections to see what the message tree looked like as it traversed through the REST API.
    • Back in the web browser, you should see the final output message carries return data from both of the back-end REST APIs which has been changed to upper case. It should look like this:
    • {"ResponseBackend1":"VALUE1","ResponseBackend2":"VALUE2"}

This tutorial has shown the Aggregation nodes orchestrating an asynchronous fan-out and an associated fan-in of messages using asynchronous REST nodes.

Find out more