Contact Us 1-800-596-4880

Predefined Variables

DataWeave 2.2 is compatible and bundled with Mule 4.2. This version of Mule reached its End of Life on May 2, 2023, when Extended Support ended.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

DataWeave expressions accept variables that can retrieve values from a variety of Mule Runtime engine objects. Before you begin, note that DataWeave version 2 is for Mule 4 apps. For a Mule 3 app, refer to the DataWeave 1.0 documentation set in the Mule 3.9 documentation. For other Mule versions, you can use the version selector for the Mule Runtime table of contents.

Commonly used variables include attributes, payload, and vars, the main parts of the Mule event.

Variables Description Fields and Examples

app

The Mule artifact in context.

  • Fields:

    • encoding: Encoding used by the Mule message processor.

    • name: Name of your project and Mule app.

    • standalone: Returns true or false.

    • workDir: Working directory for the Mule app. For Studio, this is an Eclipse plugin directory.

    • registry: Map of Mule registry entries.

  • Example: #[app.encoding] might return UTF-8.

attributes

Attributes (metadata) of a Mule Message object (message).

  • Fields: Depends on the message type, such as HTTP request attributes.

  • Example: #[attributes] returns message attributes. For an HTTP request, #[attributes.header] returns HTTP header metadata, and #[attributes.version] might return HTTP/1.1.

authentication

Provides access to the authentication information.

  • Fields:

    • principal: The main part of the authentication, such as the user or subject.

    • credentials: The credentials for the authentication.

    • properties: A map of properties for the authentication.

  • Example: #[authentication.principal]

correlationId

The correlationId of the message being processed.

  • Fields: No fields.

  • Example: #[correlationId] might return 0-f77404d0-e699-11e7-a217-38c9864c2f8f.

dataType

Data type of the message payload.

  • Fields: No fields.

  • Example: #[dataType] might return SimpleDataType.

error

Error associated with a Mule message object.

  • Fields:

    • description: Concise description of the error.

    • detailedDescription: Can provide a more thorough description.

    • errorType: The type of error.

    • cause: The internal Java Throwable that caused the error.

    • errorMessage: An optional Mule Message provided by the failing component (used by components like HTTP when a response is invalid).

    • childErrors: An optional list of internal errors (provided by components that aggregate errors, such as scatter-gather).

  • Example: #[error.description]`

flow

Deprecated: The name of the current flow. Because flow names are static, this field is deprecated and only available through the Logger component.

  • Fields:

    • name

  • Example: #[flow.name] returns testFlow in the Studio console when executed within a Flow with the name testFlow.

message

Package (payload and attributes) being processed.

  • Fields:

    • payload: The message payload, or null if the payload is null.

    • dataType: The message payload’s data type.

    • attributes: The message attributes, or null if the attributes are null.

  • Example: #[message]

mule

The Mule instance on which the application is currently running.

  • Fields:

    • clusterId: The ID of the cluster when the Mule runtime is part of a High Availability cluster.

    • home: Home directory.

    • nodeId: Cluster Node ID.

    • version: Mule version.

  • Example: #[mule.version] might return 4.0.0.

payload

The body of the current Mule message object (message) being processed.

  • Fields: Depends on the current payload.

  • Example: #[payload] returns the body of the message.

server

The operating system on which the Mule instance is running. Exposes information about both the physical server and the JVM on which Mule runs.

  • Note that the ability to select system properties, like user.name, depends on the behavior of the JVM on your operating system.

  • Fields:

    • env: Map of operating system environment variables.

    • fileSeparator: Character that separates components of a file path, which is / on UNIX and \ on Windows.

    • host: Fully qualified domain name for the server.

    • ip: IP address of the server.

    • locale: Default locale (java.util.Locale) of the JRE. Can be used language (locale.language), country (locale.country).

    • javaVendor: JRE vendor name

    • javaVersion: JRE version

    • osArch: Operating system architecture.

    • osName: Operating system name.

    • osVersion: Operating system version.

    • systemProperties: Map of Java system properties.

    • timeZone: Default time zone (java.util.TimeZone) of the JRE.

    • tmpDir: Temporary directory for use by the JRE.

    • userDir: User directory.

    • userHome: User home directory.

    • userName: User name.

  • Example: #[server.osName] might return Mac OS X.

vars

All variables currently set on the current Mule event being processed.

  • Fields: No fields.

  • Example: #[vars.myVar] returns the value of myVar.