The following example shows how to create a Message Filter route consuming messages from an endpoint called queue:a, which if the Predicate is true will be dispatched to queue:b
Using the Fluent Builders
Here is another example of using a bean to define the filter behavior
Using the Spring XML Extensions
You can also use a method call expression (to call a method on a bean) in the Message Filter, as shown below:
For further examples of this pattern in use you could look at the junit test case
Stop is a bit different than a message filter as it will filter out all messages and end the route entirely (filter only applies to its child processor). Stop is convenient to use in a Content Based Router when you for example need to stop further processing in one of the predicates.
In the example below we do not want to route messages any further that has the word
Knowing if Exchange was filtered or not
Available as of Camel 2.5
The property has the key
Using This Pattern
If you would like to use this EIP Pattern then please read the Getting Started, you may also find the Architecture useful particularly the description of Endpoint and URIs. Then you could try out some of the Examples first before trying this pattern out.