import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.core.task.TaskExecutor;
import org.springframework.kafka.core.ConsumerFactory;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
@Configuration
@EnableConfigurationProperties({ KafkaProperties.class, ApplicationProperties.class })
{
@Bean
public SimpleConsumer endlessConsumer(
+ TaskExecutor taskExecutor,
Consumer<String, String> kafkaConsumer,
- ExecutorService executor,
KafkaProperties kafkaProperties,
ApplicationProperties applicationProperties)
{
return
new SimpleConsumer(
- executor,
+ taskExecutor,
kafkaProperties.getClientId(),
applicationProperties.getTopic(),
kafkaConsumer);
}
- @Bean
- public ExecutorService executor()
- {
- return Executors.newSingleThreadExecutor();
- }
-
@Bean(destroyMethod = "close")
- public Consumer<String, String> kafkaConsumer(ConsumerFactory<String, String> factory)
+ public Consumer<?, ?> kafkaConsumer(ConsumerFactory<?, ?> factory)
{
return factory.createConsumer();
}