Search in sources :

Example 71 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot by spring-projects.

the class TaskSchedulerBuilderTests method additionalCustomizersShouldAddToExisting.

@Test
void additionalCustomizersShouldAddToExisting() {
    TaskSchedulerCustomizer customizer1 = mock(TaskSchedulerCustomizer.class);
    TaskSchedulerCustomizer customizer2 = mock(TaskSchedulerCustomizer.class);
    ThreadPoolTaskScheduler scheduler = this.builder.customizers(customizer1).additionalCustomizers(customizer2).build();
    then(customizer1).should().customize(scheduler);
    then(customizer2).should().customize(scheduler);
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Test(org.junit.jupiter.api.Test)

Example 72 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot by spring-projects.

the class TaskSchedulerBuilderTests method customizersShouldBeAppliedLast.

@Test
void customizersShouldBeAppliedLast() {
    ThreadPoolTaskScheduler scheduler = spy(new ThreadPoolTaskScheduler());
    this.builder.poolSize(4).threadNamePrefix("test-").additionalCustomizers((taskScheduler) -> {
        then(taskScheduler).should().setPoolSize(4);
        then(taskScheduler).should().setThreadNamePrefix("test-");
    });
    this.builder.configure(scheduler);
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Test(org.junit.jupiter.api.Test)

Example 73 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project spring-boot by spring-projects.

the class TaskSchedulerBuilderTests method awaitTerminationPeriodShouldApply.

@Test
void awaitTerminationPeriodShouldApply() {
    Duration period = Duration.ofMinutes(1);
    ThreadPoolTaskScheduler executor = this.builder.awaitTerminationPeriod(period).build();
    assertThat(executor).hasFieldOrPropertyWithValue("awaitTerminationMillis", period.toMillis());
}
Also used : Duration(java.time.Duration) ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Test(org.junit.jupiter.api.Test)

Example 74 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project waltz by khartec.

the class DIConfiguration method taskScheduler.

@Bean
public TaskScheduler taskScheduler() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setDaemon(true);
    return scheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)

Example 75 with ThreadPoolTaskScheduler

use of org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler in project hub-alert by blackducksoftware.

the class ApplicationConfiguration method taskScheduler.

@Bean
public TaskScheduler taskScheduler() {
    ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
    threadPoolTaskScheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
    return threadPoolTaskScheduler;
}
Also used : ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) MapJobRepositoryFactoryBean(org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ThreadPoolTaskScheduler (org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler)146 Test (org.junit.jupiter.api.Test)53 Bean (org.springframework.context.annotation.Bean)46 BeanFactory (org.springframework.beans.factory.BeanFactory)33 CountDownLatch (java.util.concurrent.CountDownLatch)23 QueueChannel (org.springframework.integration.channel.QueueChannel)23 Test (org.junit.Test)18 AtomicReference (java.util.concurrent.atomic.AtomicReference)17 GenericMessage (org.springframework.messaging.support.GenericMessage)14 ExecutorService (java.util.concurrent.ExecutorService)12 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)12 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)11 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)9 Message (org.springframework.messaging.Message)9 MessageChannel (org.springframework.messaging.MessageChannel)9 ArrayList (java.util.ArrayList)8 MessagingException (org.springframework.messaging.MessagingException)8 LogAccessor (org.springframework.core.log.LogAccessor)7 IOException (java.io.IOException)6 Socket (java.net.Socket)6