use of org.springframework.kafka.listener.KafkaMessageListenerContainer in project eventapis by kloiasoft.
the class EventApisFactory method operationsKafkaListenerContainerFactory.
@Bean("operationsKafkaListenerContainerFactory")
public KafkaListenerContainerFactory<KafkaMessageListenerContainer<String, Operation>> operationsKafkaListenerContainerFactory(ConsumerFactory<String, Operation> consumerFactory, PlatformTransactionManager platformTransactionManager) {
AbstractKafkaListenerContainerFactory<KafkaMessageListenerContainer<String, Operation>, String, Operation> abstractKafkaListenerContainerFactory = new EventApisKafkaListenerContainerFactory(consumerFactory);
RetryTemplate retryTemplate = new RetryTemplate();
abstractKafkaListenerContainerFactory.setRetryTemplate(retryTemplate);
abstractKafkaListenerContainerFactory.getContainerProperties().setPollTimeout(3000L);
abstractKafkaListenerContainerFactory.getContainerProperties().setAckOnError(false);
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(eventApisConfiguration.getEventBus().getConsumer().getOperationSchedulerPoolSize());
scheduler.setBeanName("OperationsFactory-Scheduler");
scheduler.initialize();
abstractKafkaListenerContainerFactory.getContainerProperties().setScheduler(scheduler);
// ThreadPoolTaskScheduler consumerScheduler = new ThreadPoolTaskScheduler();
// consumerScheduler.setPoolSize(30);
// consumerScheduler.setBeanName("OperationsFactory-ConsumerScheduler");
// consumerScheduler.initialize();
//
// abstractKafkaListenerContainerFactory.getContainerProperties().setConsumerTaskExecutor(consumerScheduler);
abstractKafkaListenerContainerFactory.getContainerProperties().setAckMode(AbstractMessageListenerContainer.AckMode.RECORD);
abstractKafkaListenerContainerFactory.getContainerProperties().setTransactionManager(platformTransactionManager);
return abstractKafkaListenerContainerFactory;
}
Aggregations