Friday, 8 March 2019

Mule 4 Event Model




Mule Event and Mule Message:
When a request reaches the Event source of a flow (such as an HTTP request
 or a change to a database or file).  A mule event will be generated it creates mule event object. Mule event object primarily consists of information required to process by the Mule runtime. Mule event object travels through all the components configured in mule flow.

Mule event object is immutable, so every change to an instance of a Mule event object results in the creation of a new instance.
A Mule Event object is composed of these objects:
  1. A Mule Message contains a message payload and its associated attributes.
  2.  Variables are Mule event metadata that you use in your flow.

The sequence of the activities happens when event source receives the trigger
  • 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




How the Mule Event object get created from the incoming request ?
Standard message structure consists of Header and Payload parts, where Payload is core business information that need to processed and Header contains details about payload like encryption schemes, security credentials etc. Header content also called metadata. 

When a standard message reaches the Mule Event source (in other words its called Inbound Endpoint), Event source converts that message to Mule Event Object as Mule Event processors can only understand only Mule Event object. and handovers to next event processor.

Mule Event source creates Mule Event object by coping Header contents to Attributes section and Payload contents to Payload section



<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<file:config name="File_Config" doc:name="File Config" doc:id="ce7b6ee8-e9f2-4370-b17f-2adf413d9826" >
</file:config>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="825c4787-27c3-4595-baa3-5fa66d3ca97f" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="mule_event_demoFlow" doc:id="1bbf3a21-775f-49eb-9d06-48bb9f9a51dd" >
<http:listener doc:name="Listener" doc:id="a287d233-9054-423c-818d-e73a1fa67b51" config-ref="HTTP_Listener_config" path="/"/>
<logger level="INFO" doc:name="Logger" doc:id="cb41a866-d0a9-4a06-b7f4-5f75b3c62272" message="The City from source is #[message.attributes.headers.City]"/>
<set-payload value="This payload is returned to client" doc:name="Set Payload" doc:id="2ab7bb3e-3943-4da1-9c54-c76907348924" />
</flow>
</mule>


5 comments:

  1. I am unquestionably making the most of your site. You unquestionably have some extraordinary knowledge and incredible stories. forro London

    ReplyDelete
  2. Nice blog. You have provided such a useful informartion in this blog. Thanks for sharing.
    Mulesoft Online Training

    ReplyDelete
  3. Great job you have shared here information about events planning. as we also provide Online ticket resellers in USA at affordable prices.for more info visit our website.

    ReplyDelete
  4. It is extremely nice to see the greatest details presented in an easy and understanding manner. Great Business

    ReplyDelete

  5. This is an amazing blog, thank you so much for sharing such valuable information with us.
    Mulesoft Online Course
    Mulesoft Online Training india

    ReplyDelete

How to quick start your Mulesoft professional journey

Mulesoft is leading and Fast growing Application integration framework in the industry. Do you want to start professional journey in Mulesof...