Mule Transformers
Instructions
• Prepares a message for further processing by
enhancing or altering the contents of the
message properties, variables, or payload
• Use a pre-built transformer to perform a
standard data conversion
Example
• Message source in a flow receives data in XML
format, but a downstream message processor
expects a Java object
• Use an XML-to-Object transformer to convert
the format of the message payload
Transformer Library
• Mule provides a set of standard transformers
to handle the most common data
transformation scenarios
• If Mule doesn’t have the particular
transformer, can arrange several transformers
in a sequence to achieve the output you need
Transformer Library Example
• Implement an A-to-C transformation but no such
transformer exists
• Arrange a sequence – A-to-B, B-to-C – which
effectively simulates an A-to-C transformer
• Example:
– convert XML to JSON, use an XML-to-Object
transformer followed by an Object-to-JSON
transformervely simulates an A-to-C transformer
Transformers categories - Java Object
• Each transformer in this group changes a Java
object into another Java object
• A Java object into a non-Java data type (such
as an HTTP request), or vice versa
• Example Transformers:
– JSON to Object
– XML to Object
Transformers categories - Content
• Transformers modifies messages by adding to,
deleting from, or converting a message
payload
• Example Transformers:
– Append String
– Expression
– Parse Template
– XSLT
Transformers categories - SAP
• Change SAP objects (JCo functions or IDoc
documents) into XML representations, or vice
versa
• Example Transformers:
– SAP Object to XML
– XML to SAP Function (BAPI)
– XML to SAP IDoc
Transformers categories - Script
• Utilizes a custom script to perform the
transformation
• Just add one of these to your flow, then write a script
in your favorite language to convert data as needed
• Example Transformers:
– Groovy
– JavaScript
– Python
– Ruby
– Script
Transformers categories - Properties,
Variables, and Attachments
• Add, remove, or copy properties, variables, and
attachments on the message
• Message processors doesn’t so much transform as
manipulate or enrich the contents of the message
header
• Example Transformers:
– Attachment
– Property
– Session Variable
– Variable
DataWeave Transformer
• Overview DataWeave:
– Simple, powerful tool used to query and transform data
inside of Mule
– Supports a variety of transformations: simple one-to-one,
one-to-many or many-to-one mappings from an
assortment of data structures
DataWeave Transformer
• Map an input field, such as last_name, to a different
output field, such as family_name
• Map multiple fields, such as title, first_name, and last_name,
to a composite output field such as full_name
• Retrieve session state information in a message to
facilitate conditional message routing
• Evaluation to facilitate conditional value recalculation
• Look up information in tables or other flows
Question and answer

Muletransformers

  • 1.
  • 2.
    Instructions • Prepares amessage for further processing by enhancing or altering the contents of the message properties, variables, or payload • Use a pre-built transformer to perform a standard data conversion
  • 3.
    Example • Message sourcein a flow receives data in XML format, but a downstream message processor expects a Java object • Use an XML-to-Object transformer to convert the format of the message payload
  • 4.
    Transformer Library • Muleprovides a set of standard transformers to handle the most common data transformation scenarios • If Mule doesn’t have the particular transformer, can arrange several transformers in a sequence to achieve the output you need
  • 5.
    Transformer Library Example •Implement an A-to-C transformation but no such transformer exists • Arrange a sequence – A-to-B, B-to-C – which effectively simulates an A-to-C transformer • Example: – convert XML to JSON, use an XML-to-Object transformer followed by an Object-to-JSON transformervely simulates an A-to-C transformer
  • 6.
    Transformers categories -Java Object • Each transformer in this group changes a Java object into another Java object • A Java object into a non-Java data type (such as an HTTP request), or vice versa • Example Transformers: – JSON to Object – XML to Object
  • 7.
    Transformers categories -Content • Transformers modifies messages by adding to, deleting from, or converting a message payload • Example Transformers: – Append String – Expression – Parse Template – XSLT
  • 8.
    Transformers categories -SAP • Change SAP objects (JCo functions or IDoc documents) into XML representations, or vice versa • Example Transformers: – SAP Object to XML – XML to SAP Function (BAPI) – XML to SAP IDoc
  • 9.
    Transformers categories -Script • Utilizes a custom script to perform the transformation • Just add one of these to your flow, then write a script in your favorite language to convert data as needed • Example Transformers: – Groovy – JavaScript – Python – Ruby – Script
  • 10.
    Transformers categories -Properties, Variables, and Attachments • Add, remove, or copy properties, variables, and attachments on the message • Message processors doesn’t so much transform as manipulate or enrich the contents of the message header • Example Transformers: – Attachment – Property – Session Variable – Variable
  • 11.
    DataWeave Transformer • OverviewDataWeave: – Simple, powerful tool used to query and transform data inside of Mule – Supports a variety of transformations: simple one-to-one, one-to-many or many-to-one mappings from an assortment of data structures
  • 12.
    DataWeave Transformer • Mapan input field, such as last_name, to a different output field, such as family_name • Map multiple fields, such as title, first_name, and last_name, to a composite output field such as full_name • Retrieve session state information in a message to facilitate conditional message routing • Evaluation to facilitate conditional value recalculation • Look up information in tables or other flows
  • 13.