Mule Concepts
Mule Expression Language (MEL)
Basics -III
• Basic Syntax Rules:
– #[ ] :
• Always bounds an expression.
• Example :
#[message.id]
– Simple expressions :
• The simplest type of expression.
• consist of just a context object and a field
• or simply a variable.
• Provides access to information from the message
including payload, properties, and variables.
• Example :
[message.field]
[sessionVars.age
Mule Expression Language (MEL)
• Basic Syntax Rules:
– Multi line expressions:
• You can include several lines in a single expression
• Each line must end with a ;
• Example :
#[calendar = Calendar.getInstance();
message.payload =
``neworg.mule.el.datetime.DateTime(calendar);]
– Operators :
• Performs operations in expressions
• Can be unary, comparison, logical, bitwise, arithmetic, and
more.
• Example :
#['Cookie' + flowVars.cookie]
Mule Expression Language (MEL)
• Basic Syntax Rules:
– Boolean expressions:
• Produces Boolean values.
• Example :
#['foo'=='bar']
#[2 + 2 == 4]
– Bean Property Access:
• Access information from bean.
• Example :
#[payload.property1.property2]
Mule Expression Language (MEL)
• Basic Syntax Rules:
– Method invocations:
• Calls a method.
• Then performs it on an object according to the parameter (if
any) specified within the parentheses.
• Method calls always follow the syntax:object.method()
• Example :
#[message.header.get()]
– Assignments:
• Evaluates to assign a value.
• The example below resolves dynamically to set the payload
to sample.
• Example :
#[payload = 'sample']
Mule Expression Language (MEL)
• Basic Syntax Rules:
– Literals:
• Strings, numbers, Boolean values, types, and nulls.
• Example :
'expression'
255
null
– xpath and regex:
• xpath3 and regex provide ways of extracting context
information that doesn’t already exist as a single value.
• Example :
xpath3('/orders/order[0]')
Mule Expression Language (MEL)
• Basic Syntax Rules:
– Wildcards:
• Matches a value (the message payload, by default) against
a wildcard pattern.
• these use the meta-characters '?' to represent any single
character and '*' for a repetition of any character.
• It’s case sensitive by default.
• Example :
wildcard("Hello*")
Mule Expression Language (MEL)
• Basic Syntax Rules:
– Inline list:
• Evaluates to produce a list.
• Example :
[item1, item2, . . .]
– Inline map:
• Evaluates to produce a map.
• Example :
[key1 : value1, key2: value2, …​]
– Inline array:
• Evaluates to produce an array.
• Example :
{item1, item2, . . .}
Mule Expression Language (MEL)

Mule mel 3

  • 1.
    Mule Concepts Mule ExpressionLanguage (MEL) Basics -III
  • 2.
    • Basic SyntaxRules: – #[ ] : • Always bounds an expression. • Example : #[message.id] – Simple expressions : • The simplest type of expression. • consist of just a context object and a field • or simply a variable. • Provides access to information from the message including payload, properties, and variables. • Example : [message.field] [sessionVars.age Mule Expression Language (MEL)
  • 3.
    • Basic SyntaxRules: – Multi line expressions: • You can include several lines in a single expression • Each line must end with a ; • Example : #[calendar = Calendar.getInstance(); message.payload = ``neworg.mule.el.datetime.DateTime(calendar);] – Operators : • Performs operations in expressions • Can be unary, comparison, logical, bitwise, arithmetic, and more. • Example : #['Cookie' + flowVars.cookie] Mule Expression Language (MEL)
  • 4.
    • Basic SyntaxRules: – Boolean expressions: • Produces Boolean values. • Example : #['foo'=='bar'] #[2 + 2 == 4] – Bean Property Access: • Access information from bean. • Example : #[payload.property1.property2] Mule Expression Language (MEL)
  • 5.
    • Basic SyntaxRules: – Method invocations: • Calls a method. • Then performs it on an object according to the parameter (if any) specified within the parentheses. • Method calls always follow the syntax:object.method() • Example : #[message.header.get()] – Assignments: • Evaluates to assign a value. • The example below resolves dynamically to set the payload to sample. • Example : #[payload = 'sample'] Mule Expression Language (MEL)
  • 6.
    • Basic SyntaxRules: – Literals: • Strings, numbers, Boolean values, types, and nulls. • Example : 'expression' 255 null – xpath and regex: • xpath3 and regex provide ways of extracting context information that doesn’t already exist as a single value. • Example : xpath3('/orders/order[0]') Mule Expression Language (MEL)
  • 7.
    • Basic SyntaxRules: – Wildcards: • Matches a value (the message payload, by default) against a wildcard pattern. • these use the meta-characters '?' to represent any single character and '*' for a repetition of any character. • It’s case sensitive by default. • Example : wildcard("Hello*") Mule Expression Language (MEL)
  • 8.
    • Basic SyntaxRules: – Inline list: • Evaluates to produce a list. • Example : [item1, item2, . . .] – Inline map: • Evaluates to produce a map. • Example : [key1 : value1, key2: value2, …​] – Inline array: • Evaluates to produce an array. • Example : {item1, item2, . . .} Mule Expression Language (MEL)