2. Routing
• The Routing module reviews the different types of Routers and how Routers
are used to control how messages are sent and received by components. The
message can be route in different ways. Below are explained in this example.
• Splitters and Aggregators
• Collection splitter and Collection Aggregator
• Message chunk splitter and Message chunk aggregator
• Scatter gather
• For each
• Mule flows, Sub flows and flow reference
• Filters
3. For Each:
• The Foreach scope splits a collection into elements and processes them
iteratively through the processors embedded in the scope, then returns the
original message to the flow.
4. • As For Each expects a collection object is expected a java component is used
to generate a List object.
• Above properties are available in for each scope. Collection field which
accepts MEL to provide a collection object to the for each component for
iteration. Counter Variable Name is a variable which stores the count of
iterations. Batch Size is partition the Collection into sub collections of the
specified size. Root Message Variable Name holds the message before being
split.
5. Main Flow, Sub Flow and Flow reference:
• A mule flow (main flow) which accepts message source and message
processor where sub flow accepts only message processor. Sub flow can be
called via flow reference because it doesn't accept messag source.
• Sub flow runs completely in the same context of the flow that calls it,
inheriting transcation context, exception handler, all variables and headers,
etc.
• A Main flow has its own context, transcation context, exception handler, all
variables and headers etc.
6.
7. Filters:
• Filters are used to filter the message using mule expressions.
• Above flow accepts a HTTP request and filters the message using Expression
filter and also throws an exception if Expression filter is not satisfied using
Message Filter.
8. • Expression Filter allows you to right a Mule Expression. if the expression
returns true then the process continuous to next message processor. or
else the flow get discarded without throwing any exception. Here the
condition is checking for payload instance is java.util.List or not.
9. • If we need to throw an exception when Expression Filter returns false, then
Expression filter needs wrapped up the Message Filter and
throwOnUnaccecpted attribute should be true as shown in below snippet.