Polyglot Mule Transformers

Post on 07-Jan-2017

146 views 0 download

Transcript of Polyglot Mule Transformers

POLYGLOT MULE TRANSFORMERSALLOWS DIFFERENT PROGRAMMING LANGUAGES COEXIST

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

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

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

JAVA[ This topic is discussed in different presentation ]

.NET[ This topic is discussed in different presentation ]

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.

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

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.

SCRIPT ENGINE: GROOVY (2/2)

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

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

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

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

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

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

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

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

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

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