Scopes in Mule4
Scopes in Mule4
try Scope: if any processor raises exception and we want to execute rest of processors, then we
keep the specific processor in a try block. We can catch the exception and handle it.
try with onErrorContinue: If the error occurs in try block then control comes to onErrorContinue and
provides the success response and continues to executes next processor.
try with onErrorPropagate: If the error occurs in try block then control comes to onErrorPropagate, and
it propagates back to Mainflow error handling and gives the error back to http listener response.
ForEach Scope:
► The For Each scope splits a payload into elements and processes them one by one. It is single
threaded.
► For Each does not modify the current payload. The output payload is the same as the input.
► If the variable is changed inside ForEach. These changes will be available outside of foreach
scope.
► The execution of For Each execution is stopped when an error is raised (and the Error Handler is
invoked.
► Until Successful: The Until Successful scope executes processors within it, in order. Until they
all succeed or the scope exhausts the maximum no.of retries. Until Successful runs
synchronously.
► If the final retry does not succeed, Until Successful produces an error with type
MULE:RETRY_EXHAUSTED
► Configuration properties: 1.Max Retries 2. MillisecondsBetweenRetries
► difference between Parallel For each and Scatter-Gather:
1. Parallel for each is for parallel processing of a collection/list. whereas Scatter gather is
used for Parallel processing of the whole Mule Event.
2. Parallel For each scope breaks the incoming collection/list into individual elements and
processes each in parallel. Whereas Scatter Gather keeps the incoming payload intact
without breaking it down.
Parallel Foreach
► The parallel foreach scope enables you to process a collection of messages by splitting the collection into
parts that are simultaneously processed in separate routes. After all messages are processed, the results are
aggregated following the same order they were in the before split, and then flow continues. It is multi
threaded.
► Configuration details:
Max Concurrency: specifies the maximum level of parallelism for the router to use. By default all
routes run in parallel.
collection: Specifies the expression that defines the collection of parts to be processed in
parallel. By default, it uses the incoming payload.
► Variable Propagation:
Every execution of the parallel foreach scope starts with same variable and values as before the execution of
the block.
New variables or modifications of already existing variables while processing one element are not visible while
processing of another element. All of these variables are not available out of parallelForeach scope.
► Batch processing: Batch Processing is the concept of processing a large number of
records into batches. The components are the Batch Job, Batch Step, and Batch
Aggregator.
► When the Batch Job component receives a message from an upstream processor in the
flow, the Load and Dispatch phase begins. In this phase, the component prepares the
input for processing as records, which includes creating a batch job instance in which
processing takes place.
► Variable changes inside batch step are not available at batch aggregator.
► After records pass through all Batch Step components, Mule completes the batch job
instance and reports the results in an object that indicates which records succeed
and which failed during processing.
Caching:
► The advantage of caching is to skip the execution and improves the processing speed.
► There are three types of streaming strategies available in MuleSoft:
► Repeatable file store stream (by default, this strategy is selected).
► Non repeatable stream.
► Repeatable in-memory stream.