Search

A.6. Message Filter

download PDF

Overview

A message filter, shown in Figure A.3, “Message Filter Pattern”, is a processor that eliminates undesired messages based on specific criteria. Filtering is controlled by specifying a predicate in the filter: when the predicate is true, the incoming message is allowed to pass; otherwise, it is blocked. This pattern maps to the corresponding message filter pattern in Apache Camel.

Figure A.3. Message Filter Pattern

Message filter pattern

Example ServiceMix EIP route

Example A.7, “ServiceMix EIP Message Filter” shows how to define a message filter using the ServiceMix EIP component. Incoming messages are passed through a filter mechanism that blocks messages that lack a test:world element.

Example A.7. ServiceMix EIP Message Filter

<eip:message-filter service="test:messageFilter" endpoint="endpoint">
  <eip:target>
    <eip:exchange-target service="test:trace3" />
  </eip:target>
  <eip:filter>
    <eip:xpath-predicate xpath="count(/test:world) = 1" namespaceContext="#nsContext"/>
  </eip:filter>
</eip:message-filter>

Equivalent Apache Camel XML route

Example A.8, “Apache Camel Message Filter Using XML” shows how to define an equivalent route using Apache Camel XML configuration.

Example A.8. Apache Camel Message Filter Using XML

<route>
  <from uri="jbi:endpoint:http://progress.com/demos/test/messageFilter/endpoint">
  <filter>
   <xpath>count(/test:world) = 1</xpath>
   <to uri="jbi:service:http://progress.com/demos/test/trace3"/>
  </filter>
</route>

Equivalent Apache Camel Java DSL route

Example A.9, “Apache Camel Message Filter Using Java DSL” shows how to define an equivalent route using the Apache Camel Java DSL.

Example A.9. Apache Camel Message Filter Using Java DSL

from("jbi:endpoint:http://progress.com/demos/test/messageFilter/endpoint").
  filter(xpath("count(/test:world) = 1")).
  to("jbi:service:http://progress.com/demos/test/trace3");
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.