use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project brewery by spring-cloud-samples.
the class BottlingConfiguration method threadPoolTaskScheduler.
@Bean(destroyMethod = "shutdown")
ThreadPoolTaskScheduler threadPoolTaskScheduler() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.initialize();
return threadPoolTaskScheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler 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;
}
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(5);
scheduler.setThreadNamePrefix("HydraTask");
return scheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project gravitee-gateway by gravitee-io.
the class SyncConfiguration method taskScheduler.
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setThreadNamePrefix("sync-");
return scheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-cloud-stream by spring-cloud.
the class BindingServiceTests method testLateBindingProducer.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testLateBindingProducer() throws Exception {
BindingServiceProperties properties = new BindingServiceProperties();
properties.setBindingRetryInterval(1);
Map<String, BindingProperties> bindingProperties = new HashMap<>();
BindingProperties props = new BindingProperties();
props.setDestination("foo");
final String outputChannelName = "output";
bindingProperties.put(outputChannelName, props);
properties.setBindings(bindingProperties);
DefaultBinderFactory binderFactory = createMockBinderFactory();
Binder binder = binderFactory.getBinder("mock", MessageChannel.class);
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.initialize();
BindingService service = new BindingService(properties, binderFactory, scheduler);
MessageChannel outputChannel = new DirectChannel();
final Binding<MessageChannel> mockBinding = Mockito.mock(Binding.class);
final CountDownLatch fail = new CountDownLatch(2);
doAnswer(i -> {
fail.countDown();
if (fail.getCount() == 1) {
throw new RuntimeException("fail");
}
return mockBinding;
}).when(binder).bindProducer(eq("foo"), same(outputChannel), any(ProducerProperties.class));
Binding<MessageChannel> binding = service.bindProducer(outputChannel, outputChannelName);
assertThat(fail.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(binding).isNotNull();
Binding delegate = TestUtils.getPropertyValue(binding, "delegate", Binding.class);
int n = 0;
while (n++ < 300 && delegate == null) {
Thread.sleep(100);
delegate = TestUtils.getPropertyValue(binding, "delegate", Binding.class);
}
assertThat(delegate).isSameAs(mockBinding);
service.unbindProducers(outputChannelName);
verify(binder, times(2)).bindProducer(eq("foo"), same(outputChannel), any(ProducerProperties.class));
verify(delegate).unbind();
binderFactory.destroy();
scheduler.destroy();
}
Aggregations