Using a Java method as a Predicate

Camel makes it very easy to call out to some existing Java code to act as a predicate when you are using an Enterprise Integration Pattern (EIP) such as Content Based Router or Filter. Any EIPs that require a Camel Predicate can use the Bean Expression Language to call any Java method that evaluates to a boolean value. Remember that a Camel Predicate is any Camel Expression that evaluates to a boolean value (true or false). This allows you to integrate complex decision making from your existing Java code into your routing logic.

This recipe shows you how to use any of your Java methods that returns a boolean value wherever Camel expects a predicate.

Getting ready

The Java code for this recipe is located in the ...

Get Apache Camel Developer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.