MVEL

Overview

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.

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 9, “Adding the camel-mvel dependency”.

Example 9. Adding the camel-mvel dependency

<!-- Maven POM File -->
<properties>
  <camel-version>2.11.0-fuse-00-xx</camel-version>
  ...
</properties>

<dependencies>
  ...
  <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-mvel</artifactId>
    <version>${camel-version}</version>
  </dependency>
  ...
</dependencies>

Built-in variables

Table 5, “MVEL variables” lists the built-in variables that are accessible when using MVEL.

Table 5. MVEL variables

NameTypeDescription
thisorg.apache.camel.ExchangeThe current Exchange
exchangeorg.apache.camel.ExchangeThe current Exchange
exceptionThrowablethe Exchange exception (if any)
exchangeIDStringthe Exchange ID
faultorg.apache.camel.MessageThe Fault message(if any)
requestorg.apache.camel.MessageThe IN message
responseorg.apache.camel.MessageThe OUT message
propertiesMapThe Exchange properties
property(name)ObjectThe value of the named Exchange property
property(name, type)TypeThe typed value of the named Exchange property

Example

Example 10, “Route using MVEL” shows a route that uses MVEL.

Example 10. Route using MVEL

<camelContext>
  <route>
    <from uri="seda:foo"/>
    <filter>
      <language langauge="mvel">request.headers.foo == 'bar'</language>
      <to uri="seda:bar"/>
    </filter>
  </route>
</camelContext>