DZone
Integration Zone
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
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Integration Zone > 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 · Integration Zone · Tutorial
Like (6)
Save
Tweet
16.74K 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

  • Applying Domain-Driven Design Principles to Microservice Architectures
  • SQL CTE: How to Master It in One Sitting With Easy Examples
  • Which Backend Frameworks Are Impacting Web App Development Immensely?
  • Java: Why Core-to-Core Latency Matters

Comments

Integration Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • 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:

DZone.com is powered by 

AnswerHub logo