Example usage for org.springframework.kafka.listener.adapter FilteringMessageListenerAdapter FilteringMessageListenerAdapter

List of usage examples for org.springframework.kafka.listener.adapter FilteringMessageListenerAdapter FilteringMessageListenerAdapter

Introduction

In this page you can find the example usage for org.springframework.kafka.listener.adapter FilteringMessageListenerAdapter FilteringMessageListenerAdapter.

Prototype

public FilteringMessageListenerAdapter(MessageListener<K, V> delegate,
        RecordFilterStrategy<K, V> recordFilterStrategy, boolean ackDiscarded) 

Source Link

Document

Create an instance with the supplied strategy and delegate listener.

Usage

From source file:org.springframework.kafka.config.AbstractKafkaListenerEndpoint.java

@SuppressWarnings("unchecked")
private void setupMessageListener(MessageListenerContainer container, MessageConverter messageConverter) {
    MessagingMessageListenerAdapter<K, V> adapter = createMessageListener(container, messageConverter);
    if (this.replyHeadersConfigurer != null) {
        adapter.setReplyHeadersConfigurer(this.replyHeadersConfigurer);
    }//from ww w  .j  a  v a 2 s . co  m
    Object messageListener = adapter;
    Assert.state(messageListener != null, "Endpoint [" + this + "] must provide a non null message listener");
    if (this.retryTemplate != null) {
        messageListener = new RetryingMessageListenerAdapter<>((MessageListener<K, V>) messageListener,
                this.retryTemplate, this.recoveryCallback, this.statefulRetry);
    }
    if (this.recordFilterStrategy != null) {
        if (this.batchListener) {
            if (((MessagingMessageListenerAdapter<K, V>) messageListener).isConsumerRecords()) {
                if (this.logger.isWarnEnabled()) {
                    this.logger.warn("Filter strategy ignored when consuming 'ConsumerRecords'"
                            + (this.id != null ? " id: " + this.id : ""));
                }
            } else {
                messageListener = new FilteringBatchMessageListenerAdapter<>(
                        (BatchMessageListener<K, V>) messageListener, this.recordFilterStrategy,
                        this.ackDiscarded);
            }
        } else {
            messageListener = new FilteringMessageListenerAdapter<>((MessageListener<K, V>) messageListener,
                    this.recordFilterStrategy, this.ackDiscarded);
        }
    }
    container.setupMessageListener(messageListener);
}