[[ContentFilter-eip]]
= Content Filter
:page-source: core/camel-core-engine/src/main/docs/eips/content-filter-eip.adoc

Camel supports the
http://www.enterpriseintegrationpatterns.com/ContentFilter.html[Content
Filter] from the
xref:enterprise-integration-patterns.adoc[EIP patterns]
using one of the following mechanisms in the routing logic to transform
content from the inbound message.

* xref:message-translator.adoc[Message Translator]
* invoking a xref:bean-integration.adoc[Java bean]
* xref:processor.adoc[Processor] object

image::eip/ContentFilter.gif[image]

A common way to filter messages is to use an
xref:expression.adoc[Expression] in the xref:dsl.adoc[DSL] like
xref:components::xquery-language.adoc[XQuery] or one of the supported
xref:scripting-languages.adoc[Scripting Languages].

== Using the xref:fluent-builders.adoc[Fluent Builders]

Here is a simple example using the xref:dsl.adoc[DSL] directly

In this example we add our own xref:processor.adoc[Processor]

For further examples of this pattern in use you could look at one of the
JUnit tests

* https://github.com/apache/camel/blob/master/core/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java[TransformTest]
* https://github.com/apache/camel/blob/master/core/camel-core/src/test/java/org/apache/camel/processor/TransformViaDSLTest.java[TransformViaDSLTest]

== Using Spring XML

[source,xml]
----
<route>
  <from uri="activemq:Input"/>
  <bean ref="myBeanName" method="doTransform"/>
  <to uri="activemq:Output"/>
</route>
----

You can also use XPath to filter out part of the message you are
interested in:

[source,xml]
----
<route>
  <from uri="activemq:Input"/>
  <setBody><xpath resultType="org.w3c.dom.Document">//foo:bar</xpath></setBody>
  <to uri="activemq:Output"/>
</route> 
----

[[ContentFilter-UsingThisPattern]]
== Using This Pattern

If you would like to use this EIP Pattern then please read the
xref:getting-started.adoc[Getting Started], you may also find the
xref:architecture.adoc[Architecture] useful particularly the description
of xref:endpoint.adoc[Endpoint] and xref:uris.adoc[URIs]. Then you could
try out some of the xref:examples.adoc[Examples] first before trying
this pattern out.
