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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Revolutionizing Scaled Agile Frameworks with AI, MuleSoft, and AWS: An Insider’s Perspective
  • Unlocking the Potential: Integrating AI-Driven Insights with MuleSoft and AWS for Scalable Enterprise Solutions
  • Mastering Multi-Cloud Integration: SAFe 5.0, MuleSoft, and AWS - A Personal Journey
  • AI-Generated DataWeave in MuleSoft: Production Failure Modes and How to Make It Safe

Trending

  • Why Pass/Fail CI Pipelines Are Insufficient for Enterprise Release Decisions
  • Lambda-Driven API Design: Building Composable Node.js Endpoints With Functional Primitives
  • Key Takeaways From Integrating a RAG Application With LangSmith
  • How to Test a PATCH API Request With REST-Assured Java
  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.

By 
Jitendra Bafna user avatar
Jitendra Bafna
·
Updated May. 15, 17 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
18.7K 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.

Related

  • Revolutionizing Scaled Agile Frameworks with AI, MuleSoft, and AWS: An Insider’s Perspective
  • Unlocking the Potential: Integrating AI-Driven Insights with MuleSoft and AWS for Scalable Enterprise Solutions
  • Mastering Multi-Cloud Integration: SAFe 5.0, MuleSoft, and AWS - A Personal Journey
  • AI-Generated DataWeave in MuleSoft: Production Failure Modes and How to Make It Safe

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook