|
|
|
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.kafka;
|
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
import org.springframework.boot.autoconfigure.kafka.KafkaProperties.Listener.Type;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.kafka.annotation.EnableKafka;
|
|
|
|
@ -38,7 +37,6 @@ import org.springframework.kafka.listener.RecordInterceptor;
|
|
|
|
|
import org.springframework.kafka.listener.adapter.RecordFilterStrategy;
|
|
|
|
|
import org.springframework.kafka.support.converter.BatchMessageConverter;
|
|
|
|
|
import org.springframework.kafka.support.converter.BatchMessagingMessageConverter;
|
|
|
|
|
import org.springframework.kafka.support.converter.MessageConverter;
|
|
|
|
|
import org.springframework.kafka.support.converter.RecordMessageConverter;
|
|
|
|
|
import org.springframework.kafka.transaction.KafkaAwareTransactionManager;
|
|
|
|
|
|
|
|
|
@ -55,7 +53,7 @@ class KafkaAnnotationDrivenConfiguration {
|
|
|
|
|
|
|
|
|
|
private final KafkaProperties properties;
|
|
|
|
|
|
|
|
|
|
private final RecordMessageConverter messageConverter;
|
|
|
|
|
private final RecordMessageConverter recordMessageConverter;
|
|
|
|
|
|
|
|
|
|
private final RecordFilterStrategy<Object, Object> recordFilterStrategy;
|
|
|
|
|
|
|
|
|
@ -76,7 +74,7 @@ class KafkaAnnotationDrivenConfiguration {
|
|
|
|
|
private final BatchInterceptor<Object, Object> batchInterceptor;
|
|
|
|
|
|
|
|
|
|
KafkaAnnotationDrivenConfiguration(KafkaProperties properties,
|
|
|
|
|
ObjectProvider<RecordMessageConverter> messageConverter,
|
|
|
|
|
ObjectProvider<RecordMessageConverter> recordMessageConverter,
|
|
|
|
|
ObjectProvider<RecordFilterStrategy<Object, Object>> recordFilterStrategy,
|
|
|
|
|
ObjectProvider<BatchMessageConverter> batchMessageConverter,
|
|
|
|
|
ObjectProvider<KafkaTemplate<Object, Object>> kafkaTemplate,
|
|
|
|
@ -87,10 +85,10 @@ class KafkaAnnotationDrivenConfiguration {
|
|
|
|
|
ObjectProvider<RecordInterceptor<Object, Object>> recordInterceptor,
|
|
|
|
|
ObjectProvider<BatchInterceptor<Object, Object>> batchInterceptor) {
|
|
|
|
|
this.properties = properties;
|
|
|
|
|
this.messageConverter = messageConverter.getIfUnique();
|
|
|
|
|
this.recordMessageConverter = recordMessageConverter.getIfUnique();
|
|
|
|
|
this.recordFilterStrategy = recordFilterStrategy.getIfUnique();
|
|
|
|
|
this.batchMessageConverter = batchMessageConverter
|
|
|
|
|
.getIfUnique(() -> new BatchMessagingMessageConverter(this.messageConverter));
|
|
|
|
|
.getIfUnique(() -> new BatchMessagingMessageConverter(this.recordMessageConverter));
|
|
|
|
|
this.kafkaTemplate = kafkaTemplate.getIfUnique();
|
|
|
|
|
this.transactionManager = kafkaTransactionManager.getIfUnique();
|
|
|
|
|
this.rebalanceListener = rebalanceListener.getIfUnique();
|
|
|
|
@ -105,9 +103,8 @@ class KafkaAnnotationDrivenConfiguration {
|
|
|
|
|
ConcurrentKafkaListenerContainerFactoryConfigurer kafkaListenerContainerFactoryConfigurer() {
|
|
|
|
|
ConcurrentKafkaListenerContainerFactoryConfigurer configurer = new ConcurrentKafkaListenerContainerFactoryConfigurer();
|
|
|
|
|
configurer.setKafkaProperties(this.properties);
|
|
|
|
|
MessageConverter messageConverterToUse = (this.properties.getListener().getType().equals(Type.BATCH))
|
|
|
|
|
? this.batchMessageConverter : this.messageConverter;
|
|
|
|
|
configurer.setMessageConverter(messageConverterToUse);
|
|
|
|
|
configurer.setBatchMessageConverter(this.batchMessageConverter);
|
|
|
|
|
configurer.setRecordMessageConverter(this.recordMessageConverter);
|
|
|
|
|
configurer.setRecordFilterStrategy(this.recordFilterStrategy);
|
|
|
|
|
configurer.setReplyTemplate(this.kafkaTemplate);
|
|
|
|
|
configurer.setTransactionManager(this.transactionManager);
|
|
|
|
|