12
Mule Expression Language - Part 1 Karthik Selvaraj

Mule expression language - Part 1

Embed Size (px)

Citation preview

Page 1: Mule expression language - Part 1

Mule Expression Language - Part 1

Karthik Selvaraj

Page 2: Mule expression language - Part 1

IntroductionMule Expression Language (MEL) was

introduced in Mule 3.3.0Prior to version 3.3.0, expressions in Mule

varied in syntax according to their specific evaluator.

The variation in syntax rules was time-consuming to learn and hence MEL was created to address this complexity.

Mule Expression Language (MEL), implements a single set of syntax rules.

Page 3: Mule expression language - Part 1

Expression VS Scripting languageAn 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.

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 you need to get or set values, invoke methods, or perform functions, you can do so quickly and easily using an expression language. 

Page 4: Mule expression language - Part 1

MEL – Assigning ValuesPoint the cursor to value field and press

CTRL + Space key to get the list of values to assign

Page 5: Mule expression language - Part 1

MEL Context ObjectsContext Objects

server: this object provides access to the fields for the hardware, operating system, user, and network interface.

mule: this object provides access to the fields for your Mule instance.

app: this object provides access to the fields of your Mule application.

message: this object provides access to the fields of the Mule message.

Page 6: Mule expression language - Part 1

MEL VariablesVariables

flowVarssessionVars

UsageflowVars

#[flowVars.firstname = Karthik]sessionVars

#[sessionVars.lastname = Selvaraj]

Page 7: Mule expression language - Part 1

MEL VariableYou can use the variable name directly in a

MEL expression#[firstname] is equivalent to #[flowVars.firstname]#[lastname] is equivalent to #[sessionVars.lastname]

Mule assumes that it is a flowVars and, when MEL evaluates the expression, looks for a variable by that name. If Mule cannot find a flowVars by that name, it looks for a sessionVars by that name before failing.

Page 8: Mule expression language - Part 1

MEL VariableIf you wish to disable this auto-resolution of

variables by name, please include the below flow configuration xml <configuration> <expression-language

autoResolveVariables="false"/> </configuration>

Page 9: Mule expression language - Part 1

MEL Variable

Page 10: Mule expression language - Part 1

Referencehttps://

docs.mulesoft.com/mule-user-guide/v/3.7/mule-expression-language-mel

https://docs.mulesoft.com/mule-user-guide/v/3.6/mule-expression-language-basic-syntax

https://docs.mulesoft.com/mule-user-guide/v/3.6/mule-expression-language-reference

https://docs.mulesoft.com/mule-user-guide/v/3.6/mule-expression-language-examples

https://docs.mulesoft.com/mule-user-guide/v/3.7/mule-expression-language-tips

Page 12: Mule expression language - Part 1

Mule Expression Language

THANK YOU