Enterprise Integration Patterns - Message Filter
A Message Filter is a special form of a Content-Based Router. It examines the message content and passes the message to a service only if the message content matches certain criteria, otherwise the message is discarded.
If a consumer wishes to receive only messages whose content satisfy a given criteria, a message filter can be inserted on the message path to filter out unwanted messages. The consumer can focus on processing the requests it expects and does not have the overhead of processing each incoming message and discarding those it is not interested in processing
Messages with sensitive/private content can be hidden from services which should not be receiving them by inserting a message filter, on the path to these services, which filters out the sensitive messages.
filter [type] [name | expression]
type := filter implementation (xpath, regex)
name := named configuration which contains the filter details
expression := inline filter configuration
Xpath filter with inline configuration
filter xpath ("//orders/order")
Xpath filter with external configuration
filter xpath "ordersOnlyConfig"
$ cat ordersOnlyConfig/flow.properties
In both the examples above only those messages which match the xpath expression will be allowed to continue.