/** * Set the executor for threads that poll the consumer. * @param consumerTaskExecutor the executor * @return the spec. * @see ContainerProperties#setConsumerTaskExecutor(AsyncListenableTaskExecutor) */ public KafkaMessageListenerContainerSpec<K, V> consumerTaskExecutor( AsyncListenableTaskExecutor consumerTaskExecutor) { this.container.getContainerProperties().setConsumerTaskExecutor(consumerTaskExecutor); return this; }
/** * Set the executor for threads that poll the consumer. * @param consumerTaskExecutor the executor * @return the spec. * @see ContainerProperties#setConsumerTaskExecutor(AsyncListenableTaskExecutor) */ public KafkaMessageListenerContainerSpec<K, V> consumerTaskExecutor( AsyncListenableTaskExecutor consumerTaskExecutor) { this.container.getContainerProperties().setConsumerTaskExecutor(consumerTaskExecutor); return this; }
@Bean("operationsKafkaListenerContainerFactory") public ConcurrentKafkaListenerContainerFactory<String, Operation> operationsKafkaListenerContainerFactory( ConsumerFactory<String, Operation> consumerFactory, PlatformTransactionManager platformTransactionManager) { ConcurrentKafkaListenerContainerFactory<String, Operation> factory = new ConcurrentKafkaListenerContainerFactory<>(); factory.setConsumerFactory(consumerFactory); RetryTemplate retryTemplate = new RetryTemplate(); factory.setRetryTemplate(retryTemplate); factory.setConcurrency(eventApisConfiguration.getEventBus().getConsumer().getOperationSchedulerPoolSize()); ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); scheduler.setPoolSize(eventApisConfiguration.getEventBus().getConsumer().getOperationSchedulerPoolSize()); scheduler.setBeanName("OperationsFactory-Scheduler"); scheduler.initialize(); factory.getContainerProperties().setScheduler(scheduler); ThreadPoolTaskScheduler consumerScheduler = new ThreadPoolTaskScheduler(); consumerScheduler.setPoolSize(eventApisConfiguration.getEventBus().getConsumer().getOperationSchedulerPoolSize()); consumerScheduler.setBeanName("OperationsFactory-ConsumerScheduler"); consumerScheduler.initialize(); factory.getContainerProperties().setPollTimeout(3000L); factory.getContainerProperties().setAckOnError(false); factory.getContainerProperties().setConsumerTaskExecutor(consumerScheduler); factory.getContainerProperties().setAckMode(AbstractMessageListenerContainer.AckMode.RECORD); factory.getContainerProperties().setTransactionManager(platformTransactionManager); return factory; }