此内容没有您所选择的语言版本。
Chapter 23. MVEL
Overview 复制链接链接已复制到粘贴板!
MVEL 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 复制链接链接已复制到粘贴板!
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 复制链接链接已复制到粘贴板!
To use MVEL in your routes you need to add a dependency on camel-mvel
to your project as shown in Example 23.1, “Adding the camel-mvel dependency”.
Example 23.1. Adding the camel-mvel dependency
Built-in variables 复制链接链接已复制到粘贴板!
Table 23.1, “MVEL variables” lists the built-in variables that are accessible when using MVEL.
Name | Type | Description |
---|---|---|
|
| The current Exchange |
|
| The current Exchange |
|
| the Exchange exception (if any) |
|
| the Exchange ID |
|
| The Fault message(if any) |
|
| The IN message |
|
| The OUT message |
|
| The Exchange properties |
|
| The value of the named Exchange property |
|
| The typed value of the named Exchange property |
Example 复制链接链接已复制到粘贴板!
Example 23.2, “Route using MVEL” shows a route that uses MVEL.
Example 23.2. Route using MVEL