use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project eventapis by kloiasoft.
the class EventApisFactory method operationsKafkaListenerContainerFactory.
@Bean("operationsKafkaListenerContainerFactory")
public ConcurrentKafkaListenerContainerFactory<String, Operation> operationsKafkaListenerContainerFactory(ConsumerFactory<String, Operation> consumerFactory) {
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(ContainerProperties.AckMode.RECORD);
/**
* This is Fix for Spring Kafka versions which does not have ConsumerAwareErrorHandler handler till 2.0
* When Listener faces with error, it retries snapshot operation
* See https://github.com/kloiasoft/eventapis/issues/44
*/
factory.getContainerProperties().setTransactionManager(new EmptyTransactionManager());
// factory.getContainerProperties().setTransactionManager(platformTransactionManager);
return factory;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project eventapis by kloiasoft.
the class EventApisFactory method eventsKafkaListenerContainerFactory.
@Bean({ "eventsKafkaListenerContainerFactory", "kafkaListenerContainerFactory" })
public ConcurrentKafkaListenerContainerFactory<String, PublishedEventWrapper> eventsKafkaListenerContainerFactory(EventMessageConverter eventMessageConverter, ConsumerFactory<String, PublishedEventWrapper> consumerFactory) {
ConcurrentKafkaListenerContainerFactory<String, PublishedEventWrapper> factory = new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactory);
factory.setConcurrency(eventApisConfiguration.getEventBus().getConsumer().getEventConcurrency());
factory.setMessageConverter(eventMessageConverter);
factory.getContainerProperties().setPollTimeout(3000);
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(eventApisConfiguration.getEventBus().getConsumer().getEventSchedulerPoolSize());
scheduler.setBeanName("EventsFactory-Scheduler");
scheduler.initialize();
factory.getContainerProperties().setScheduler(scheduler);
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.RECORD);
return factory;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project nzbhydra2 by theotherp.
the class HydraTaskConfiguration method taskExecutor.
@Bean
public ThreadPoolTaskScheduler taskExecutor() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(1);
scheduler.setThreadNamePrefix("HydraTask");
scheduler.setThreadGroupName("HydraTask");
return scheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot by spring-projects.
the class TaskExecutorMetricsAutoConfigurationTests method taskSchedulersWithCustomNamesAreInstrumented.
@Test
void taskSchedulersWithCustomNamesAreInstrumented() {
this.contextRunner.withBean("firstTaskScheduler", Executor.class, ThreadPoolTaskScheduler::new).withBean("customName", ThreadPoolTaskScheduler.class, ThreadPoolTaskScheduler::new).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
Collection<FunctionCounter> meters = registry.get("executor.completed").functionCounters();
assertThat(meters).map((meter) -> meter.getId().getTag("name")).containsExactlyInAnyOrder("firstTaskScheduler", "customName");
});
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot by spring-projects.
the class PrometheusPushGatewayManagerTests method shutdownWhenDoesNotOwnSchedulerDoesNotShutdownScheduler.
@Test
void shutdownWhenDoesNotOwnSchedulerDoesNotShutdownScheduler() {
ThreadPoolTaskScheduler otherScheduler = givenScheduleAtFixedRateWillReturnFuture(mock(ThreadPoolTaskScheduler.class));
PrometheusPushGatewayManager manager = new PrometheusPushGatewayManager(this.pushGateway, this.registry, otherScheduler, this.pushRate, "job", this.groupingKey, null);
manager.shutdown();
then(otherScheduler).should(never()).shutdown();
}
Aggregations