Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

DataWeave Variables for Mule Runtime

DataWeave expressions accept variables that can retrieve values from a variety of Mule Runtime objects. 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.

  • 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

correlationId

  • 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.

flow

An accessor to the flow that provides the current’s name.

  • Fields:

    • name

  • Example: #[flow.name] will return testFlow when executed within a Flow named 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 running.

  • Fields:

    • clusterId: Cluster ID.

    • home: Home directory.

    • nodeId: Cluster Node ID.

    • version: Mule version.

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

payload

The body of a Mule message object (message).

  • 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. It exposes information about both the physical server and JRE on which Mule runs.

  • 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 version

    • javaVersion: JRE vendor name

    • 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

A variable set on the Mule event.

  • Fields: No fields.

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