Scatter-Gather Flow Control

(3 reviews)

home

This example shows the usage of the scatter-gather control flow to aggregate data in parallel and return the result in JSON.

ddd7a3a0-Screen Shot 2018-08-06 at 12.30.34 PM.png

The example uses prepared data as input for two resources that should be aggregated. The data represents information about two contacts and has the following structure:

Resourcefirstnamesurnamephoneemail
contacts-1.csvJohnDoe096548763john.doe@texasComp.com
contacts-2.csvJaneDoe091558780jane.doe@texasComp.com

DataWeave is used to aggregate the data.

The information about the contacts is aggregated to a JSON structure that represents data from both resources (contacts-1.csv and contacts-2.csv).

Assumptions

This document describes the details of the example within the context of Anypoint™ Studio, Mule ESB’s graphical user interface (GUI). This document assumes that you are familiar with Mule Runtime and the Anypoint Studio interface. Further, this example assumes that you have a basic understanding of Mule flows, and Anypoint DataWeave.

Example Use Case

In this example, sample data is prepared with the Expression component, and the prepared data serves as input for aggregation in the Scatter-Gather component. Then, the report is transformed to CSV format and sent to an email address via the SMTP connector. This example has been configured for Gmail.

Set Up and Run this Example
  1. Open the Scatter Gather Flow Control project in Anypoint Studio from Anypoint Exchange.
  2. In the application in Studio, click the Global Elements tab.
  3. Double-click the HTTP Listener global element to open its Global Element Properties panel.
  4. Change the contents of the Port field to the required HTTP port (e.g., 8081).
  5. Click the File connector labeled Read contacts-1.csv file and, in the File Path field of its properties panel, navigate to the file contacts-1.csv and click Open. Do the same for the File connector Read contacts-2.csv file.
  6. Right-click the project in the Package Explorer and run the project as a Mule application.
  7. Open your Web browser.
  8. In the address bar, type the following URL: http://localhost:8081/scatterGather
  9. Press enter to elicit a response from the Scatter-Gather flow control example.

Reviews

TypeExample
OrganizationMuleSoft
Published by
MuleSoft Organization
Published onSep 12, 2018
Asset overview

Asset versions for 2.1.x

Asset versions
VersionActions
2.1.4
2.1.3
2.1.2