Expressions
Expressions and Predicates can then be used to create the various Enterprise Integration Patterns in the DSL like with the Content Based Router EIP, or Recipient List EIP.
To support dynamic rules Camel supports pluggable Expression strategies using a variety of different Languages.
| The Simple is often used as predicates and expressions with the Camel EIPs. |
If you are outside the DSL and want to create your own expressions you can either implement the Expression interface, reuse one of the other builders or try the ExpressionBuilder class.
Expression API
The API for a Camel Expression is defined in the org.apache.camel.Expression interface as shown:
public interface Expression {
/**
* Returns the value of the expression on the given exchange
*
* @param exchange the message exchange on which to evaluate the expression
* @param type the expected type of the evaluation result
* @return the value of the expression
*/
<T> T evaluate(Exchange exchange, Class<T> type);
} A Expression is being evaluated to an Object value. This makes expressions so powerful as this can be used for functions, data mapping, templating, and for low-code users.