2. EXPRESSION LANGUAGE
• An expression language, such as MEL, is similar, but not the same as, a scripting
language: it allows you to write short scripts that resolve dynamically to get
values, set values, or perform an operation on data. There is an overlap in
functionality between an expression language and a scripting language, but
scripting languages are generally more useful if you are writing something
complex enough to require more than just a few lines of code, or if you need to
include conditional logic. If, however, you need to get or set values, invoke
methods, or perform functions, you can do so quickly and easily using an
expression language.
3. MULE EXPRESSION LANGUAGE
• Mule specific lightweight language.
• It is use for accessing data in the mule message
(payload, variable, properties).
4. BENEFITS OF MEL
Once upon a time, when developing Mule applications, you would have had little other
option than to use a scripting language, such as Groovy, or a programming language
such as Java, to manipulate the contents of a message object. Though effective, using
these languages was not always efficient because there was no consistent, standardized
method for evaluating expressions.
Enter MEL, an expression language that provides a consistent, standardized way for
developers to work with a Mule message’s payload, properties and variables. It makes
use of Mule-specific context objects, it’s easy to use (auto-complete everywhere!) and it
behaves well when testing your application. Further, and most importantly, MEL enforces
consistency when accessing information on the message: rather than using multiple
expression evaluators, you can use MEL, the default expression evaluator, to consistently
access and manipulate information.
5. USING MEL
• It supports following types of operation:
• Extract information from the message.
• Evaluate conditions
• Define a target
6. EXTRACT INFORMATION FROM MESSAGE
• #[payload] – Return payload
• #[message.inboundProperties.'propertyName'] – return inbound property name
• #[payload.methodCall(parameters)] – return result of methodCall
• #[xpath3('//root/element1')] - evaluate xpath expression
8. DEFINE A TARGET
• #[flowVars.output] – access a variable name output.
• We can also do it in java. It has MuleMessage class as below:
• MuleMessage message = new MuleMessage();
• message.getinvocationProperty(“output”) – will return output as
string.