Content Filter

Camel supports the Content Filter from the EIP patterns using one of the following mechanisms in the routing logic to transform content from the inbound message.


Message Content filtering using a Processor

In this example we add our own Processor using explicit Java to filter the message:

    .process(new Processor() {
        public void process(Exchange exchange) {
            String body = exchange.getMessage().getBody(String.class);
            // do something with the body
            // and replace it back

Message Content filtering using a Bean EIP

we can use Bean EIP to use any Java method on any bean to act as content filter:

    .bean("myBeanName", "doFilter")

And in XML DSL:

    <from uri="activemq:Input"/>
    <bean ref="myBeanName" method="doFilter"/>
    <to uri="activemq:Output"/>

Message Content filtering using expression

Some languages like XPath, and XQuery can be used to transform and filter content from messages.

In the example we use xpath to filter a XML message to select all the <foo><bar> elements:


And in XML DSL:

  <from uri="activemq:Input"/>
  <to uri="activemq:Output"/>