Anypoint Studio Transformers helps us to transform the message to required format which helps in easy integration with other systems. You can use in built transformers given by Mule or you can develop a new custom on your own.
2. 4/4/2016 Manirathnam Gudi
Transformers are used to transform message or event payloads to and from
different types
Transformers are used to convert inbound data to an object type required by the
UMO Component or outbound to an object type required by the transport such as a
JMS Message.
Multiple transformers can be chained together to get a finer grained transformer
implementation that are easier to reuse.
3. 4/4/2016 Manirathnam Gudi
How to alter the message using Transformers
Transformer can alter a message in different ways:
Payload type transformation- The data type of the message payload is transformed from one form to
another.
Example: java.util.Map is transformed into a javax.jms.MapMessage.
Payload format transformation- The data format of the message payload is transformed from one form to
another.
Example: DocBook XML instance is transformed into an XSL-FO instance.
Properties transformation- The properties of the message are modified, whether by adding new
properties or by removing, renaming, or changing the values of existing properties.
Example: Message needs a particular property to be set before being sent to a JMS destination
5. 4/4/2016 Manirathnam Gudi
Transformers can be configured in two ways.
Configure it locally - We can configure a local transformer at any point in the program or on the
endpoint or in a Flow .
Configure it Globally – We can also configure a global transformer before any <model> or <flow>
elements in your Mule configuration file and later reference it.
How to configure Transformer
6. 4/4/2016 Manirathnam Gudi
Types of Transformers
Transformers can be categorized into two types :
Built-in Transformers
Custom Transformers
Default Transformers : There are many Standard pre existing Transformers provided in Mule
3.7 which can be used easily to convert the data.
For example :
Object to JSON Transformer
Object to String Transformer
JMS Message to Object Transformer
Object to JMS Message
Object to XML
XML to Object
7. 4/4/2016 Manirathnam Gudi
Custom Transformers :
If you are not satisfied with the default/built in transformers which are already provided by Anypoint
Studion (or) If there is any no transformer which meets your requirement then you can develop a
transformer on your own by customizing the code by writing the java code by implementing a Custom
transformer class org.mule.api.transformer.Transformer .
Depending on your needs we can extend AbstractTransformer or AbstractMessageAwareTransformer .
We build Custom transformers if it's impossible to realize with an existing transformer or a chain of
transformers.