use of org.springframework.kafka.core.KafkaTemplate in project SONG by overture-stack.
the class KafkaConfig method kafkaTemplate.
@Bean
public KafkaTemplate<String, String> kafkaTemplate() {
val template = new KafkaTemplate<>(producerFactory());
template.setDefaultTopic(defaultTopic);
return template;
}
use of org.springframework.kafka.core.KafkaTemplate in project spring-boot by spring-projects.
the class KafkaAutoConfiguration method kafkaTemplate.
@Bean
@ConditionalOnMissingBean(KafkaTemplate.class)
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);
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;
}
Aggregations