title: Spring Boot: how to use FilteringMessageListenerAdapter
body: <p>I have a Spring Boot application which listens to messages on a Kafka queue. To filter those messages, have the following two classs</p>
  
  <pre><code>@Component
  public class Listener implements MessageListener {
      private final CountDownLatch latch1 = new CountDownLatch(1);
  
      @Override
      @KafkaListener(topics = "${spring.kafka.topic.boot}")
      public void onMessage(Object o) {
          System.out.println("LISTENER received payload *****");
          this.latch1.countDown();
      }
  }
  
  @Configuration
  @EnableKafka
  public class KafkaConfig {
  
      @Autowired
      private Listener listener;
  
      @Bean
      public FilteringMessageListenerAdapter filteringReceiver() {
          return new FilteringMessageListenerAdapter(listener, recordFilterStrategy() );
      }
  
      public RecordFilterStrategy recordFilterStrategy() {
          return  new RecordFilterStrategy() {
  
              @Override
              public boolean filter(ConsumerRecord consumerRecord) {
                  System.out.println("IN FILTER");
                  return false;
              }
          };
      }
  }
  </code></pre>
  
  <p>While messages are being processed by the <code>Listener</code> class, the <code>RecordFilterStrategy</code> implementation is not being invoked. What is the correct way to use <code>FilteringMessageListenerAdapter</code>?</p>
  
  <p>Thanks</p>