0% found this document useful (0 votes)
22 views11 pages

Scopes in Mule4

The document discusses various scopes in Mule 4, including Async Scope, Try Scope, ForEach Scope, Until Successful, Parallel ForEach, and Batch Processing, detailing their functionalities and configurations. It also covers caching strategies and streaming options available in MuleSoft, explaining the differences between repeatable file store streams, non-repeatable streams, and repeatable in-memory streams. Each scope and strategy is designed to optimize processing and error handling in Mule applications.

Uploaded by

satya kolli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views11 pages

Scopes in Mule4

The document discusses various scopes in Mule 4, including Async Scope, Try Scope, ForEach Scope, Until Successful, Parallel ForEach, and Batch Processing, detailing their functionalities and configurations. It also covers caching strategies and streaming options available in MuleSoft, explaining the differences between repeatable file store streams, non-repeatable streams, and repeatable in-memory streams. Each scope and strategy is designed to optimize processing and error handling in Mule applications.

Uploaded by

satya kolli
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Scopes in mule4

Youtube link: https://www.youtube.com/watch?v=cAhHxj5I4dA


Async Scope:
► async scope is the one where we want to execute subset of event processors parallelly with the flow
where we don't have a dependency. AsyncScope executes simultaneously with mainflow.
► whatever payload inside async scope will not get outside like as foreach scope(payload is not
modified). we can store a payload into a variable, and we access it from outside of async scope.
► Async can be useful for executing time-consuming operations that do not require you to send a
response back to the initiating flow (such as printing a file or connecting to a mail server).
• Does not inherit the exception strategy of the main flow. To handle errors in an Async scope, use the
Try scope.
► .max concurrency: Sets the maximum number of concurrent messages that the scope can process

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.

Repeatable file store stream:


For 0.1 vCore there is 8GB of memory available, what MuleSoft provides to us is 512 MB as
Heap memory. After 512 MB is full, data will be stored in the disk storage which is the
remaining memory (8GB - 512MB (some installations let us assume 1.5 GB)).
► Non Repeatable Stream:
In this streaming strategy, when the very first time you are reading the input payload, the
memory assignment and everything work as Repeatable File Stream strategy but once
read, the payload data will be cleared from the memory and disk space, and you cannot
read it again.
► Repeatable In-Memory Stream
This streaming strategy is a bit different from others. In this, the data will be stored in
memory (heap memory), it will not be stored in disk space. So if you pass payload more
than heap size, it will throw memory out of bound exception.

You might also like