The Mule message is the data which crosses an application through flows. It comprises two main components: message header and payload.
A Mule message is also integrated into a Mule message object. Some of the Mule message objects may include variables, exception payloads and attachments.
Become a master of Mulesoft by going through this HKR Mulesoft Training!
The metadata inside the message header includes properties that provide helpful information regarding the message. The variables in the message object represent the data on a message.
Variables and Properties have a common format: every variable or property contains a name and a value. The name is the way in which you refer to the variable or property in Mule, and the value is the information stored in it. Therefore name acts as a key of the door, and value acts as the material in the back of the door.
The properties and variables of a message have specific scopes which will define and organize the way they apply to the whole life cycle of that message. The properties send metadata as well as a message to make processing easier and avoid mistakes when the message passes through the transport barrier, either by being sent to a different application or by entering a new flow.
The properties have two major scopes. They are inbound and outbound.
Variables are the metadata related to the message set by the user. The variables have three scopes. They are:
Variables are temporary information elements about a message that the application should use that processes it instead of conveying it with the message at its destination. This means that Humans can set variables while the properties are set and invoked by the systems. However, strict rules on the use of properties and variables do not exist.
Mule has three message processors that can be used to define, copy, or delete outbound variables and properties on a message in a flow. Mule will add, copy or delete metadata message object or header when we include these transformers in the flow. A fourth message processor exists: the record variable processor may define or delete variables on a record within a batch. It focuses solely on the message processors that act on the messages.
[Related Article: Mulesoft Tutorial]
The payload of the message is the main part of the Mule message as it holds the data that your Mule application deals with. You can use metadata in the message object or message header for communicating information related to your message or prevent it from being altered. The payload does not necessarily remain the same since it moves through a flow. Different message processors within a Mule flow may affect the payload along the way by configuring, enhancing, or transforming it to a new format. You can also retrieve data from a payload into a flow using a MEL expression.
In some instances, you may call an external resource and use the response to enhance the payload of the message instead of replacing it. You can do this by using a message enricher scope to encapsulate the message processors performing the information retrieval task. Once this is done, Mule adds or expands the payload of the message with the result of a call to the resource.
A mule message structure can be viewed at any point of the flow. Simply select an element in the flow and click on the DataSense icon. Then DataSense Explorer is opened and shows both the message structure that enters elements and the message structure exits it. It helps know the properties and names of variables which are available at this point, along with the internal structure of the payload.
In this blog, we have gone through the mule message structure, Mule header, message payload, variables and properties of a message and the way variables and properties of a message are configured. Hope you found this information useful.
Batch starts on 8th Aug 2021, Weekend batch
Batch starts on 12th Aug 2021, Weekday batch
Batch starts on 16th Aug 2021, Weekday batch