use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project codekvast by crispab.
the class SchedulingConfig method taskScheduler.
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(5);
return scheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project elastest-torm by elastest.
the class StompTestUtils method connectToRabbitMQ.
public static StompSession connectToRabbitMQ(int serverPort) throws InterruptedException, ExecutionException, TimeoutException {
WebSocketContainer cont = ContainerProvider.getWebSocketContainer();
cont.setDefaultMaxTextMessageBufferSize(65500);
WebSocketClient webSocketClient = new StandardWebSocketClient(cont);
WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);
stompClient.setMessageConverter(new StringMessageConverter());
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.initialize();
// for heartbeats
stompClient.setTaskScheduler(taskScheduler);
stompClient.setDefaultHeartbeat(new long[] { 10000, 10000 });
String url = "ws://localhost:" + serverPort + "/rabbitMq";
StompSessionHandler sessionHandler = new LogConnectedSessionHandler();
final int MAX_RETRIES = 5;
int retry = 0;
while (true) {
try {
StompSession stompSession = stompClient.connect(url, sessionHandler).get(10, TimeUnit.SECONDS);
log.info("Test connected to RabbitMQ in URL '{}'", url);
return stompSession;
} catch (Exception e) {
if (retry < MAX_RETRIES) {
retry++;
log.warn("Exception trying to connect to RabbitMQ: {}:{}", e.getClass().getName(), e.getMessage());
log.info("Retrying {}/{} in 5 second", retry, MAX_RETRIES);
Thread.sleep(5000);
} else {
throw e;
}
}
}
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project alien4cloud by alien4cloud.
the class SchedulingConfiguration method getPaaSScheduler.
@Bean(name = "paas-monitor-scheduler")
public Executor getPaaSScheduler() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(paasMonitorThreadPoolSize);
threadPoolTaskScheduler.setThreadNamePrefix("paas-monitor-");
return threadPoolTaskScheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project cloudbreak by hortonworks.
the class AsyncConfig method taskScheduler.
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new MDCCleanerThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(TASK_SCHEDULER_POOL_SIZE);
threadPoolTaskScheduler.setThreadNamePrefix("scheduledExecutor-");
return threadPoolTaskScheduler;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot-admin by codecentric.
the class RegistrationApplicationListenerTest method should_no_schedule_register_task_when_not_autoRegister.
@Test
public void should_no_schedule_register_task_when_not_autoRegister() {
ApplicationRegistrator registrator = mock(ApplicationRegistrator.class);
ThreadPoolTaskScheduler scheduler = mock(ThreadPoolTaskScheduler.class);
RegistrationApplicationListener listener = new RegistrationApplicationListener(registrator, scheduler);
listener.setAutoRegister(false);
listener.onApplicationReady(new ApplicationReadyEvent(mock(SpringApplication.class), null, mock(ConfigurableWebApplicationContext.class)));
verify(scheduler, never()).scheduleAtFixedRate(isA(Runnable.class), eq(Duration.ofSeconds(10)));
}
Aggregations