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(
Consumer<String, String> kafkaConsumer,
- ExecutorService executor,
KafkaProperties kafkaProperties,
ApplicationProperties applicationProperties)
{
return
new SimpleConsumer(
- executor,
kafkaProperties.getClientId(),
applicationProperties.getTopic(),
kafkaConsumer);
}
- @Bean
- public ExecutorService executor()
- {
- return Executors.newSingleThreadExecutor();
- }
-
@Bean(destroyMethod = "close")
public Consumer<?, ?> kafkaConsumer(ConsumerFactory<?, ?> factory)
{