Filters

Message filters are Spring Integration components, which act as an interceptor and decide whether to pass on the message to the next channel/component or drop it. Unlike routers, which decide what should be the next channel for a message, filters only take a boolean decision—whether to pass or not. There are two ways to define a message filter in Spring Integration:

  • Write a simple Java class and designate its method that will take decisions whether to pass the message or not
  • Configure it as a message endpoint that delegates to an implementation of the MessageSelector interface

This can be configured either in XML or annotations can be used.

Using a Java class to act as a filter

Let's take an example of using a simple Java class as a filter—this ...

Get Spring Integration Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.