|
|
|
@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.boot.autoconfigure.kafka.KafkaProperties.Jaas;
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
import org.springframework.boot.context.properties.PropertyMapper;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.annotation.Import;
|
|
|
|
@ -66,10 +67,13 @@ public class KafkaAutoConfiguration {
|
|
|
|
|
public KafkaTemplate<?, ?> kafkaTemplate(ProducerFactory<Object, Object> kafkaProducerFactory,
|
|
|
|
|
ProducerListener<Object, Object> kafkaProducerListener,
|
|
|
|
|
ObjectProvider<RecordMessageConverter> messageConverter) {
|
|
|
|
|
|
|
|
|
|
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
|
|
|
|
KafkaTemplate<Object, Object> kafkaTemplate = new KafkaTemplate<>(kafkaProducerFactory);
|
|
|
|
|
messageConverter.ifUnique(kafkaTemplate::setMessageConverter);
|
|
|
|
|
kafkaTemplate.setProducerListener(kafkaProducerListener);
|
|
|
|
|
kafkaTemplate.setDefaultTopic(this.properties.getTemplate().getDefaultTopic());
|
|
|
|
|
map.from(kafkaProducerListener).to(kafkaTemplate::setProducerListener);
|
|
|
|
|
map.from(this.properties.getTemplate().getDefaultTopic()).to(kafkaTemplate::setDefaultTopic);
|
|
|
|
|
map.from(this.properties.getTemplate().getTransactionIdPrefix()).to(kafkaTemplate::setTransactionIdPrefix);
|
|
|
|
|
return kafkaTemplate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|