Using MEL with Batch Processing
Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version. |
All of the functions and attributes below are usable within MEL expressions anywhere in Mule where the context makes sense.
MEL Attributes Related to Batch Jobs
These attributes can be referenced in any element inside or after your batch job:
Attribute | Description |
---|---|
|
Use to access record variables by name. |
|
Total number of records in the batch. |
|
Number of records loaded in Loading phase. |
|
Number of records processed at this point. |
|
Number of records processed and failed in at least one step. |
|
ID of the batch job instance |
|
Exception object for exception in Input phase. |
|
Exception object for exception in Loading phase. |
|
Exception object for exception in Complete phase. |
MEL Functions that Involve Batch Jobs
These functions can be used anywhere in your batch jobs, in any component that supports MEL expressions.
Function |
Description |
|
Boolean function indicating processing status of record. |
|
Boolean function indicating processing status of record. |
|
Boolean function indicating whether or not batch processing failed at the Input phase. |
|
Boolean function indicating whether or not batch processing failed at Loading phase. |
|
Boolean function indicating whether or not batch processing failed at Complete phase. |
|
Receives the name of a step as a String argument. If the current record threw exception on that step, then it returns the actual Exception object. Otherwise it returns null |
|
Returns a java Map<String, Exception> in which the keys are the name of a batch step in which the current record has failed and the value is the exception object itself. If the record hasn’t failed in any step, this Map will be empty, not null. Also, the Map contains no entries for steps in which the record hasn’t failed. |
|
Returns the Exception object for the very first step in which the current record has failed. If the record hasn’t failed in any step, then it returns null. |
|
Returns the Exception object for the last step in which the current record has failed. If the record hasn’t failed in any step, then it returns null. |
Example Use of A MEL Function in a Batch Job
For example, suppose you have a batch job with the following Batch Step:
Here you can add the following expression into the Set Payload transformer:
In this case, this expression will return a Java Map for the current record where the key is the name of the batch step and the value is the exception object. This expression will of course only evaluate batch steps through which the current record has already passed, it can’t evaluate any batch steps that may come after it.
See Also
-
Read a Blog Post about handling errors with Batch
-
Read more about using Mule Expression Language (MEL)in your application