The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Mule 3 has three commonly used variable scopes: flowVars for flow-level state, sessionVars for session-level state, and recordVars for state attached to an individual batch record. They differ in where data belongs and how it is accessed. In Mule 4, use vars; Mule 3 recordVars examples are legacy syntax.
How Mule 3 variable scopes differ
Choose a scope according to what the value belongs to: the flow’s message processing, the session context, or one record in a batch. MuleSoft’s Mule 3.9 MEL reference explains that flow variables are available through the flowVars context or, in some cases, as top-level variables. Mule 3.9 MEL reference
| Scope | What it belongs to | Mule 3 access syntax | Migration note |
|---|---|---|---|
| Flow variable | Flow-level state associated with message processing | flowVars.foo |
Mule 4 uses vars.foo. |
| Session variable | State accessed through the Mule 3 session-variable context | sessionVars.foo |
The supplied Mule 4 references do not establish a direct session-variable equivalent; assess the value’s required lifetime and use case during migration. |
| Record variable | State attached to a particular record in a Mule 3 batch | recordVars['foo'] |
MuleSoft says Mule 4 variables (vars) replace Mule 3 recordVars. |
These variable scopes are not the same thing as MuleMessage property scopes—such as inbound, outbound, invocation, and session properties. MuleSoft treats those as separate parts of MuleMessage handling. MuleSoft’s MuleMessage scope comparison
Using flowVars in MEL
Use a flow variable when a value is needed as flow-level state, for example to preserve a payload before transforming it. MuleSoft’s Mule 3.9 reference shows setting originalPayload from message.payload and later using that value as the payload again. Mule 3.9 MEL reference
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
<set-variable variableName="originalPayload" value="#[message.payload]" />
<set-payload value="#[flowVars.originalPayload]" />
In MEL, read the value as flowVars.originalPayload. The Mule 3.9 reference also documents top-level access, but that depends on autoResolveVariables not being false and the variable name following MVEL naming conventions. The explicit flowVars form makes the scope clear.
Setting and reading session variables
Mule 3 provides a session-variable processor and access through the sessionVars context. The official reference gives this XML example:
<set-session-variable variableName="sessionId" value="#[message.id+'@'+mule.nodeId]" />
An expression component can assign the same value with MEL:
sessionVars.sessionId = message.id+'@'+mule.nodeId
Read a session variable through sessionVars, for example sessionVars.sessionId. Mule 3.9 MEL reference Mule 3.9 session-variable reference
Rank #3
When to use recordVars in a batch job
Use recordVars when the value belongs to the current batch record, not to the message as a whole. MuleSoft’s migration guide describes Mule 3 record-level variables as attaching values to a particular record, in contrast to flowVars, which apply to the Mule message. Its example modifies both record.payload and record.recordVars['marco']. MuleSoft batch migration guide
This distinction matters when a batch contains multiple records: record-specific state should stay associated with its record rather than being treated as message-wide state. Use the bracket form shown above to access a named record variable.
Rank #4
What replaces recordVars in Mule 4?
MuleSoft states that Mule 4 variables (vars) replace Mule 3 recordVars. For example, Mule 4 accesses a variable as vars.foo, rather than using the Mule 3 recordVars['foo'] form. MuleSoft batch migration guide The current Mule 4 variable documentation describes variables accessed through vars and carried through downstream processors and flow references. Mule 4 variable reference
Keep Mule 3 syntax labeled as legacy when documenting or migrating an application. Do not assume that Mule 3’s flowVars or sessionVars syntax carries over unchanged: Mule 4’s variable model is documented separately, and the cited migration statement specifically identifies the replacement for recordVars.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

