String
Scripting Module Reference - Mule 4
Scripting Module v2.1
The Scripting module executes custom logic written in a scripting language.
Operations
Execute
<scripting:execute>
Run a script with provided code, according to the engine and passing parameters. The script provides many binding variables to work with:
Name | Type | Description |
---|---|---|
payload |
Object |
The payload of the message processed. |
dataType |
Data type of the message payload. |
|
correlationId |
String |
The correlationId of the message processed. |
attributes |
Map<String, Object> |
Attributes of the Mule message processed. |
vars |
Map<String, Object> |
The variables set on the current Mule event processed. |
message |
The message processed. |
|
error |
Error associated with the Mule message processed. |
|
authentication |
Information about the authentication. |
|
flow |
String |
The name of the current flow. |
log |
Logger |
Logger object that logs to the app’s log file, |
result |
Object |
Variable representing the result of the script execution. |
registry |
org.mule.runtime.api.artifact.Registry |
Use the registry object to access any other service within the Mule API. |
If the code doesn’t produce an implicit result, you have to set the result variable value explicitly with the execution result. The payload is set with this value unless you configure a target variable as described in Scripting Module Overview.
|
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Code |
The script source code to execute |
x |
||
Engine |
String |
Name of the scripting engine for running this script |
x |
|
Parameters |
Map<String, Object> |
Variables provided to the script as bindings |
||
Target Variable |
String |
The name of a variable on which to place the operation’s output |
||
Target Value |
String |
An expression to evaluate against the operation’s output. The outcome of that expression will be stored in the target variable. |
#[payload] |
You must export the classes used with the Scripting Module, otherwise, the execution fails with a SCRIPTING:COMPILATION error. See how to export resources.
|
Types
Aggregation Attributes
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Aggregation Id |
String |
Aggregation ID that comes from the event’s message correlationId. If the aggregator does not aggregate by correlationId, then this field is an autogenerated value for the current aggregated group. |
x |
|
First Item Arrival Time |
Number |
Time in which the first aggregated value arrived. |
x |
|
Last Item Arrival Time |
Number |
Time in which the last aggregated element arrived. |
x |
|
Is Aggregation Complete |
Boolean |
A boolean value that indicates the completion of the aggregation. |
false |
Redelivery Policy
Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Max Redelivery Count |
Number |
Maximum number of times that a redelivered request can be processed unsuccessfully before returning a REDELIVERY_EXHAUSTED error. |
||
Use Secure Hash |
Boolean |
If |
||
Message Digest Algorithm |
String |
Secure hashing algorithm to use if the <b>Use Secure Hash<b/> field is |
||
Id Expression |
String |
One or more expressions that determine when a message was redelivered. This property can be set only if the <b>Use Secure Hash</b> field is |
||
Object Store |
ObjectStore |
Configures the object store that stores the redelivery counter for each message. |