• Event and Message Model
Mule 4 introduce a simplified Mule Event and Message model. Here the flows are triggered by an event.
  • An Event contains a Message and variables associated with it.
  • A Message is composed of a payload and its attributes (metadata, such as file size).
  • Variables hold arbitrary information, such as Messages, payload data, or attributes.
  • Mule Events
A Mule event contains the core information processed by the runtime. It travels through components inside your Mule app following the configured application logic.
Note that the Mule event is immutable, so every change to an instance of a Mule event results in the creation of a new instance.
A Mule Event is composed of these objects:
  • A Mule Message contains a message payload and its associated attributes.
  • Variables are Mule event metadata that you use in your flow.
A Mule event is generated when a trigger (such as an HTTP request or a change to a database or file) reaches the Event source of a flow.
This trigger could be an external event triggered by a resource that might be external to the Mule app.
  •   A trigger reaches the event source.
  •   The event source produces a Mule event.
  •   The Mule event travels sequentially through the components of a flow.
  •   Each component interacts in a pre-defined manner with the Mule event.
A Mule message is created as part of a Mule event when a Message source in a Mule flow triggers a flow to start, as when an HTTP listener receives a response or each time the Scheduler component triggers an execution of the flow.
For example:
When an HTTP listener in a Mule app receives a response, it creates a Mule event with a Mule message that contains the content of the response as its payload along with the metadata associated with that content, such as HTTP headers, as it attributes. Message processors in the flow (such as Core components, File read operations, or the HTTP request operations) can then retrieve, set, and process Mule message data that resides in the Mule event according to their configurations.
  • Message Payload
The message payload contains the content or body of a message.
The payload can contain the results of an HTTP request, the content of records you retrieve through the Select operation of the Database connector etc.
The payload content changes as it travels through a flow when message processors in a Mule flow set it, enrich it, transform it into a new format, extract information from it, or even store it in a Mule event variable and produce a new payload.
At anywhere inside a mule appliaction, if we want to access the Massage payload we can use "#[payload]" expression.
Example: JSON input (payload)
  • Attributes
Attributes contain the metadata associated with the body (or payload) of the message.
The specific attributes of a message depend on the connector (such as HTTP, FTP, File) associated with the message. Metadata can consist of headers and properties received or returned by a connector, as well as other metadata that is populated by the connector or through a Core component, such as Transform Message.
At anywhere inside a mule appliaction, if we want to access the Attributes we can use "#[attributes.header]", "#[attributes.uriParams]", "#[attributes.method]", etc.
Example: Sample HTTP Request Attributes

If you got some knowledge about "Mule 4 Message Structure", please follow with me in next topic to understand about "Mule4 - Thread Management and Self-Tuning Runtime".

Comments