- Overview
Variables are used to store per-event values for use within a flow of a Mule app.
Variables are used to store values for use within a Mule flow in a Mule application.
Variables can store a current message, current message payload, or current message attributes.
In Mule 3, there are 3 types of variables:
- Flow variables, apply only to the flow in which they exist.
- Session variables, apply across all flows within the same application.
- Record variables, apply to only to records processed as part of a batch.
- Flow Variables
Use a variable transformer to set or remove a variable on the message.
Flow variables cannot cross the transport barriers. It means, if you want access flow variable after HTTP or any other connector, it will not be available.
Flow Variables can pass from one Flow to another privateFlow or subFlow only when using a flow reference component.
Syntax to access flow variable is : #[flowVars.firstName], where firstName is the name of the flow variable.
- Session Variable
Use a session variable transformer to set or remove a variable on the message.
Session variables can be easily propagated from one flow to another through the VM transport, or a flow reference, but not through the HTTP Connector.
So, we can say session variable can cross a transport barrier, but except HTTP Connector.
Syntax to access session variable is : #[sessionVars.firstName], where firstName is the name of the session variable.
- Record Variable
With batch processing gives the ability to set, remove, and reference variables associated to individual records.
Serialised and persisting only through the Process phase, a record variable stores information at the record level, rather than the flow or session level.
Record Variables, unlike any other variable, are special variable sets that are used only inside a Batch Job.
Record Variables are available or accessed only in the process phase of the Batch job.
Records Variable are accessed using the syntax: #[recordVars.firstName], where firstName is the name of Record Variable.
Comments