Choice, Scatter-Gather Router & Foreach in Mule 4

Mulesoft

Dear #Trailblazers,

Welcome back, this is the Episode #3 of Mulesoft ranger series and we are going to learn about below topics. Find the agenda for Mulesoft Series Episode #3

Subflow in Mule 4

subflow is a scope that enables you to group event processors in a manner similar to that of a flow, but with certain differences and limitations:

  • Subflows do not have event sources.
  • Subflows do not have an error handling scope.
  • During design, subflows work as macros that replace the Flow Reference components that call them.
    When you build the application, all Flow Reference components that call a subflow are replaced by the contents of the referenced subflow.
  • Referencing subflows results in better performance than referencing a flow.

Choice Router in Mule 4

The Choice router dynamically routes messages through a flow according to a set of DataWeave expressions that evaluate message content. 

Image copyrights to mulesoft.com

Choice Router Schematic
Image copyrights to mulesoft.com
Image copyrights to mulesoft.com

Scatter-Gather Router in Mule 4

The routing message processor Scatter-Gather sends a request message to multiple targets concurrently. It collects the responses from all routes, and aggregates them into a single message.

Image copyrights to mulesoft.com
Image copyrights to mulesoft.com

Example: Flight Booking

When you try to bool a flight, you have to enter source, destination and the dates. After clicking on search you many results from various airlines. So to get the data and make it faster ( improve the performance ), behind the scenes all the request are being made in parallel

Connect with Database in mule 4 using connector check this Link.

Image copyrights to mulesoft.com
Image copyrights to mulesoft.com

For Each in mulesoft Mule 4

The For Each scope splits a payload into elements and processes them one by one through the components that you place in the scope. It is similar to a for-each/for loop code block in most programming languages and can process any collection, including lists and arrays. The collection can be any supported content type, such as application/jsonapplication/java, or application/xml.

Here is the full video for your reference

Resources

  1. https://docs.mulesoft.com/
  2. http://training.mulesoft.com/
  3. https://www.mulesoft.com/resources/covid-19
  4. https://dzone.com/ for Mulesoft
  5. SFDCPanther YouTube channel
  6. Tech Lightning YouTube channel

Happy Learning. #KeepSharing #KeepLearning #AskPanther

Sharing is caring šŸ™‚