Polyglot Mule Transformers

18
POLYGLOT MULE TRANSFORMERS ALLOWS DIFFERENT PROGRAMMING LANGUAGES COEXIST

Transcript of Polyglot Mule Transformers

Page 1: Polyglot Mule Transformers

POLYGLOT MULE TRANSFORMERSALLOWS DIFFERENT PROGRAMMING LANGUAGES COEXIST

Page 2: Polyglot Mule Transformers

BASIC CONSIDERATIONS• Anypoint Studio provides a set of transformers to

handle the most common data transformation scenarios•Developer can chain transformers if a transformer

did not exist for specific needs• The DataWeave Transform Message component can

be used in place of most other transformers

Page 3: Polyglot Mule Transformers

SPECIAL CASES• Transforming complex data structures• Applying complex business rules• The available transformers cannot meet the requirement• Simply throw the old lines of code into a component

instead of having to reengineer the code’s behavior through a series of different Mule components

Page 4: Polyglot Mule Transformers

POSSIBLE SOLUTIONS•Building custom components and/or transformers• Turning to the most favorite Programming

Languages:o Javao .NETo Scripting languages: Groovy, Javascript, Python or Ruby

Page 5: Polyglot Mule Transformers

JAVA[ This topic is discussed in different presentation ]

Page 6: Polyglot Mule Transformers

.NET[ This topic is discussed in different presentation ]

Page 7: Polyglot Mule Transformers

SCRIPT COMPONENT (1/2)Basic usage: To set up in the scripting component, identify what scripting engine to use, and the script itself, which you can reference or type directly into the element.

Page 8: Polyglot Mule Transformers

SCRIPT COMPONENT (2/2)Choose a programming language for the scripting component:• Groovy• JavaScript• Python• Ruby

Page 9: Polyglot Mule Transformers

SCRIPT ENGINE: GROOVY (1/2)Placing a Groovy (JavaScript, Python, or Ruby) Component is actually the same as placing a Script component and then selecting the Groovy (JavaScript, Python, or Ruby) engine.

Page 10: Polyglot Mule Transformers

SCRIPT ENGINE: GROOVY (2/2)

Specify the file location of the script or simply type in the script on the script text window.

Page 11: Polyglot Mule Transformers

SCRIPT ENGINE: JAVASCRIPTJavaScript allows the developer to configure interceptors and alter the values or references of particular properties in a script.

Page 12: Polyglot Mule Transformers

SCRIPT ENGINE: PYTHONPython allows the developer to configure interceptors and alter the values or references of particular properties in a script.

Page 13: Polyglot Mule Transformers

SCRIPT ENGINE: RUBYRuby allows the developer to configure interceptors and alter the values or references of particular properties in a script.

Page 14: Polyglot Mule Transformers

POLYGLOT: DESIGN (DEMO)Putting all available Scripting Languages in a row.

Page 15: Polyglot Mule Transformers

POLYGLOT: IMPLEMENTATION<![CDATA[return "Groovy\n"]]>

<![CDATA[message.payload = payload + "JavaScript\n";result = message;]]><![CDATA[result = payload + "Python\n"]]>

<![CDATA[return $payload + "Ruby\n"]]>

Page 16: Polyglot Mule Transformers

POLYGLOT: EXECUTIONExecuting the configuration via a browser or REST client:

Page 17: Polyglot Mule Transformers

SUMMARYMule allows developers to:•Build their own component and/or transformer• Simply write their favorite programming language• Put the different programming languages in a row