Warning: A non-numeric value encountered in /home/ricston2/public_html/blogarchive/wp-content/themes/Divi/functions.php on line 5766

One question that is often asked (directly or indirectly) on the Mule forums relates to transformation. Some people are unsure whether transformation should be done on the inbound endpoint or the outbound endpoint and some others think that it is the same thing. This post attempts to clarify all this.

Firstly, I’d like to ask you to read my description of the Inbound Flow Stage. As explained there, any transformation is then fed into the component, if you have one declared, so if you want to transform the data before the component gets it, then the inbound-endpoint is the only logical place for it.

This situation is pretty obvious, and in fact confusion arises when there is no component at all and the data is going to be bridged from the inbound-endpoint to the outbound-endpoint. Things to consider:

1 – Default transformations by the transport. JMS, for example, will automatically use the JMSMessageToObject transformer when a message is read off a JMS endpoint. If your transformer works on the original JMSMessage, then you can place it on the inbound-endpoint (and it will work) but moving this transformation to the outbound-endpoint means that the transformer will receive an object and not the JMS Message. The same applies to the outbound-endpoint; a web service endpoint is going to package the data into a SOAP envelope so any outbound transformation needs to operate on the original MuleMessage not on the raw XML that is sent out.
2 – Changes caused by filters and/or routers. It is not good practice to change a message inside a filter or a router. Filters are there to filter only. Routers are there to route. Transformers are meant to, erm, transform the message. However, an incorrectly coded filter or router may change the message before it reaches the outbound-endpoint.
3 – Interceptors. Any interceptor has access to the entire message and can change it too.