2. Mule Message Enricher is an important component in Mule.
The Mule Message Enricher allows the current message to be used in performing
a particular task separately without disturbing the original message.
The task will be performed and the current message will not be changed or
disturbed
3. So, how can we use Message Enricher in Mule ????
4. Mule Message Enricher is the block or scope where we can put our message
processors that will perform a certain task without modifying the actual payload
5. Let’s consider a flow where we will set a payload and call an external service,
extract a value of an element from response and will log the extracted value
from the response as well as the original payload at the end of the flow
6. Our Mule Config will be :-
You can see that we are calling an external web service, getting it’s response,
extracting an element value from the response and storing into a variable.
At the end of the flow we are logging both the variable and
undisturbed original payload
7. This is how it works :-
You can see the Original payload which is a SOAP request for the external service is undisturbed
and can be logged at the end of the flow in a logger. In mean time the payload is used in the
Message Enricher block to call the external service, transformed into SOAP XML, and extract a
value from SOAP response using XPATH and stored in a flow variable
8. To test the application, if we hit the url http://localhost:8081/test , we will get
in our log :-
You can see in logs both the variable and the original payload are logged in
console
9. In my next slide I will bring some other techniques in Mule
implementation .
Hope you have enjoyed this simpler version.