Scatter Gather Flow Control
home
Learn how to use scatter-gather flow control to send a message to multiple processors in parallel.
Screenshot of the main flow in Anypoint Studio, view full image here
Description
This example shows us the usage of the scatter-gather flow control to send the same message to a logger and a gmail account in parallel.
Example Use Case
In this example a sample data in JSON format is received through an using the Java Object Transformer. Then the string representation of the JSON object is logged to the console and it is also sent to an email address using the SMTP connector. This example has been configured for gmail.
Set Up and Run this Example
Open the project in the studio interface
Navigate to src/main/app/scatter-gather.xml and edit Send an email via SMTP component as follows:
# Basic settings Host: smtp.gmail.com Port: 587 User: senderemailid%40gmail.com Password: senderpassword # Email information To: receiveremailid@gmail.com From: senderemailid@gmail.com Subject: Processing Finished Report
Run the project as a Mule application
Send a sample JSON data to your localhost server running your mule application.
Sample JSON data: { "a": 3, "b": 4 }
Login to receiveremailid@gmail.com to verify if the data was received via email. You could also verify the studio console to check if you received a message from the Logger Component as follows:
INFO 2014-07-03 16:10:00,974 [[scatter-gather-master].ScatterGatherWorkManager.01] org.mule.api.processor.LoggerMessageProcessor: Processing finished: {a=3, b=4}
##Documentation
Read full documentation in GitHub
Examples to Try Next
If you understood this example | |
---|---|
Importing Email Attachments using the POP3 Connector - Learn how to use the POP3 connector to transfer information via email. | View |
If you struggled with this example | |
---|---|
HTTP Request Response with Logger - Learn how to use Mule to build a simple HTTP request-response application. | View |