DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Multicasting (Scatter-Gather) Messages With MuleSoft

Multicasting (Scatter-Gather) Messages With MuleSoft

Scatter Gather is used to send messages to multiple destinations concurrently and aggregate the responses into a message.

Jitendra Bafna user avatar by
Jitendra Bafna
CORE ·
May. 15, 17 · Tutorial
Like (6)
Save
Tweet
Share
17.12K Views

Join the DZone community and get the full member experience.

Join For Free

Multicasting of messages with Mulesoft can be achieved using Scatter-Gather, which concurrently casts messages to each route. It collects results from all the routes and aggregates them into a single message.

During Scatter-Gather processing, if any of the routes fail, it doesn't stop sending messages to other configured routes — so it is possible that one or more configured routes can fail concurrently.

By default, if any of the routers fail during Scatter-Gather processing, the following action will be performed:

  • Set an exception payload for each failed route.

  • Throw a CompositeRoutingException.

CompositeRoutingException extends MessagingException to aggregate exceptions from different routes in the context of a single message router. Exceptions are correlated to each route through a sequential ID.

Scatter-Gather applications will not start if you have configured with less than two routes. It should always contain two or more routes.

Let's walk through setting up Scatter-Gather with Mule application.

Setting Up HTTP Listener With Mule Flow

First, you need to place the HTTP listener to the source of Mule flow and configure it. You can invoke the Mule flow by sending a request over HTTP.

Image title

Configuring Scatter-Gather Route With Mule Flow

Now, you need to drop the Scatter-Gather route in the Message Processor of the Mule Flow. You need to send a message concurrently to multiple routes via HTTP, JMS, Web Service Consumer, File, etc.  To achieve this, we will add different connectors under the Scatter-Gather route, place them in parallel, and configure all the connectors in the Scatter-Gather route.Image title

In the above screenshot, you can see that TransformMessage has been used after Web Service Consumer and HTTP Requestor. Basically, we are getting results back from both endpoints and we are transforming both responses to a single generic format as a response from both routes will be in a different format.

One more transformation has been placed at the end of the Scatter-Gather route. This transformation aggregates the result from all the routes to the single message.

Image title

Testing the Application

You can use Postman to test the application. We will use the HTTP GET method to send a request to invoke the Mule flow.

Image title

Conclusion

Scatter-Gather is used to send messages to multiple destinations concurrently and aggregate the response from all into a single message. It is a very simple technique provided by Mulesoft to multicast messages.

I hope that this article clarifies all of the doubt that you may have with the Scatter-Gather route.

Here is the video tutorial:


MuleSoft

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Apache Kafka vs. Memphis.dev
  • DevOps Roadmap for 2022
  • How to Quickly Build an Audio Editor With UI
  • Cloud Native London Meetup: 3 Pitfalls Everyone Should Avoid With Cloud Data

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: