package de.juplo.kafka;
-import org.apache.kafka.clients.producer.KafkaProducer;
-import org.apache.kafka.clients.producer.Producer;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
-import org.springframework.kafka.core.ProducerFactory;
-
-import java.util.Properties;
+import org.springframework.kafka.core.KafkaTemplate;
@Configuration
public RestGateway restGateway(
ApplicationProperties applicationProperties,
KafkaProperties kafkaProperties,
- Producer<String, Integer> kafkaProducer)
+ KafkaTemplate<String, Integer> kafkaTemplate)
{
return
new RestGateway(
kafkaProperties.getClientId(),
- applicationProperties.getTopic(),
applicationProperties.getPartition(),
- kafkaProducer);
- }
-
- @Bean(destroyMethod = "close")
- public Producer<String, Integer> kafkaProducer(ProducerFactory<String, Integer> factory)
- {
- return factory.createProducer();
+ kafkaTemplate);
}
}