Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 20. MVEL
Overview Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
MVEL (http://mvel.codehaus.org/) is a Java-based dynamic language that is similar to OGNL, but is reported to be much faster. The MVEL support is in the
camel-mvel
module.
Syntax Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
You use the MVEL dot syntax to invoke Java methods, for example:
getRequest().getBody().getFamilyName()
getRequest().getBody().getFamilyName()
Because MVEL is dynamically typed, it is unnecessary to cast the message body instance (of
Object
type) before invoking the getFamilyName()
method. You can also use an abbreviated syntax for invoking bean attributes, for example:
request.body.familyName
request.body.familyName
Adding the MVEL module Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
To use MVEL in your routes you need to add a dependency on
camel-mvel
to your project as shown in Example 20.1, “Adding the camel-mvel dependency”.
Example 20.1. Adding the camel-mvel dependency
Built-in variables Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Table 20.1, “MVEL variables” lists the built-in variables that are accessible when using MVEL.
Name | Type | Description |
---|---|---|
this | org.apache.camel.Exchange | The current Exchange |
exchange | org.apache.camel.Exchange | The current Exchange |
exception | Throwable | the Exchange exception (if any) |
exchangeID | String | the Exchange ID |
fault | org.apache.camel.Message | The Fault message(if any) |
request | org.apache.camel.Message | The IN message |
response | org.apache.camel.Message | The OUT message |
properties | Map | The Exchange properties |
property(name) | Object | The value of the named Exchange property |
property(name, type) | Type | The typed value of the named Exchange property |
Example Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Example 20.2, “Route using MVEL” shows a route that uses MVEL.
Example 20.2. Route using MVEL