What is the scope of variables in Mule 4 Batch Job Processing

Scope of variables in Batch processing of Mule 4


Which variables are accessible in the Batch Job Instance?


Every processed record of the Batch Job Instance starts with the same variables and values present before the execution of the block. Every record has its own set of variables, so new variables or modifications of already-existing variables during the processing of a given record will not be visible while processing another record. 
For each record, those variables (and modifications) are propagated through the different Batch Steps. For example, if record R1001 sets a variable varName: "hello", record R2 sets varName: "world", and record R3 does not set this variable, then in the next step, R1 will see the value "hello", R2 the value "world" and R3 will not see any value for that variable.

Moreover, since the Batch Job Instance executes asynchronously from the rest of the flow, no variable set in either a Batch Step or the On Complete phase will be visible outside the Batch Scope.

Also Read: Scope of variables in Scatter Gather router of Mulesoft

What data is available in the On Complete phase?


In the On Complete phase, none of the variables are accessible. Only the final result is available in this phase. During this phase, you can optionally configure the runtime to create a report or summary of the records it processed for the particular batch job instance. This phase exists to give system administrators and developers some insight into which records failed to address any issues that might exist with the input data.

Example of Batch Processing in Mulesoft (Mule 4.2 Runtime)



Logs:

From the logs, it is evident that On Complete Phase does not log any payload information





Post a Comment

0 Comments