Message State
• To better understand how Mule message processors
act upon messages, it is useful to examine the state of
a message before and after it is processed. When a
transformer converts the content of a message payload
from one data structure to another, or from one data
format to another
• For example, JSON to Java Object, Map to CSV, or Java
Object to XML – you may wonder exactly how Mule
has changed, removed or added to the contents of a
message. Reviewing its "before and after" state should
help you to be better able to work with the message
further in the flow.
• Message Header
• Message Payload
• Properties
• Variables
• After DataMapper
• Message Header
• Message Payload
• Properties
• Variables
• More Examples
• Setting a Variable on a Message
• Setting a Property on a Message
• Setting a Payload on a Message
Message Header
• The Message (see image below) contains data
from the header of the message (i.e. metadata).
In this example, you can see the message's
identifiers and determine if there are
attachments, which would be arrays if they
existed.
• Note that the Message Processor name indicates
a Value of DataMapper; the Message Processor
item indicates the next message processor in the
flow that the message will encounter.
Message Payload
• The payload (see image below), not
surprisingly, contains the payload of the
message, or rather, the data that the Mule
application processes. Before it encounters
the DataMapper, the payload contains a CSV
file – currentFile – with type java.io.File.
Properties
• The Visual Debugger also displays any inbound
and outbound properties on the message as it
enters the DataMapper. The Inbound
Properties on the message include metadata
about the payload, including its filename,
timstamp and the endpoint through which it
entered the application,
MULE_ORIGINATING_ENDPOINT. Inbound
properties are read-only and cannot be added,
removed or copied by message processors in the
application.
Variables
• The Visual Debugger displays any variables or
session variables included in the message
object as it encounters the DataMapper. The
File endpoint in this flow set two Variables on
the message to indicate where DataMapper
should move the file after processing, and the
frequency with which the endpoint polls the
input folder for new data.
Setting a Variable on a Message
• The Variable transformer in a flow sets the
payload of the message as a minPrice variable on
the message. Recall that the Message Processor
item indicates the next message processor in the
flow that the message will encounter.
• <flow>
• <set-variable doc:name="Variable"
value="#[payload]" variableName="minPrice"/>
• </flow>

Message state

  • 1.
  • 2.
    • To betterunderstand how Mule message processors act upon messages, it is useful to examine the state of a message before and after it is processed. When a transformer converts the content of a message payload from one data structure to another, or from one data format to another • For example, JSON to Java Object, Map to CSV, or Java Object to XML – you may wonder exactly how Mule has changed, removed or added to the contents of a message. Reviewing its "before and after" state should help you to be better able to work with the message further in the flow.
  • 3.
    • Message Header •Message Payload • Properties • Variables • After DataMapper • Message Header • Message Payload • Properties • Variables • More Examples • Setting a Variable on a Message • Setting a Property on a Message • Setting a Payload on a Message
  • 4.
    Message Header • TheMessage (see image below) contains data from the header of the message (i.e. metadata). In this example, you can see the message's identifiers and determine if there are attachments, which would be arrays if they existed. • Note that the Message Processor name indicates a Value of DataMapper; the Message Processor item indicates the next message processor in the flow that the message will encounter.
  • 5.
    Message Payload • Thepayload (see image below), not surprisingly, contains the payload of the message, or rather, the data that the Mule application processes. Before it encounters the DataMapper, the payload contains a CSV file – currentFile – with type java.io.File.
  • 6.
    Properties • The VisualDebugger also displays any inbound and outbound properties on the message as it enters the DataMapper. The Inbound Properties on the message include metadata about the payload, including its filename, timstamp and the endpoint through which it entered the application, MULE_ORIGINATING_ENDPOINT. Inbound properties are read-only and cannot be added, removed or copied by message processors in the application.
  • 7.
    Variables • The VisualDebugger displays any variables or session variables included in the message object as it encounters the DataMapper. The File endpoint in this flow set two Variables on the message to indicate where DataMapper should move the file after processing, and the frequency with which the endpoint polls the input folder for new data.
  • 8.
    Setting a Variableon a Message • The Variable transformer in a flow sets the payload of the message as a minPrice variable on the message. Recall that the Message Processor item indicates the next message processor in the flow that the message will encounter. • <flow> • <set-variable doc:name="Variable" value="#[payload]" variableName="minPrice"/> • </flow>