Search in sources :

Example 51 with ThreadPoolTaskExecutor

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

the class TaskExecutorBuilderTests method taskDecoratorShouldApply.

@Test
void taskDecoratorShouldApply() {
    TaskDecorator taskDecorator = mock(TaskDecorator.class);
    ThreadPoolTaskExecutor executor = this.builder.taskDecorator(taskDecorator).build();
    assertThat(executor).extracting("taskDecorator").isSameAs(taskDecorator);
}
Also used : TaskDecorator(org.springframework.core.task.TaskDecorator) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Test(org.junit.jupiter.api.Test)

Example 52 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method clientOutboundChannelExecutor.

@Bean
public TaskExecutor clientOutboundChannelExecutor() {
    TaskExecutorRegistration reg = getClientOutboundChannelRegistration().taskExecutor();
    ThreadPoolTaskExecutor executor = reg.getTaskExecutor();
    executor.setThreadNamePrefix("clientOutboundChannel-");
    return executor;
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Bean(org.springframework.context.annotation.Bean)

Example 53 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.

the class GenericMessagingTemplateTests method setup.

@BeforeEach
public void setup() {
    this.messageChannel = new StubMessageChannel();
    this.template = new GenericMessagingTemplate();
    this.template.setDefaultDestination(this.messageChannel);
    this.template.setDestinationResolver(new TestDestinationResolver());
    this.executor = new ThreadPoolTaskExecutor();
    this.executor.afterPropertiesSet();
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) StubMessageChannel(org.springframework.messaging.StubMessageChannel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 54 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.

the class MessageBrokerConfigurationTests method clientOutboundChannelCustomized.

@Test
public void clientOutboundChannelCustomized() {
    ApplicationContext context = loadConfig(CustomConfig.class);
    AbstractSubscribableChannel channel = context.getBean("clientOutboundChannel", AbstractSubscribableChannel.class);
    assertThat(channel.getInterceptors().size()).isEqualTo(4);
    ThreadPoolTaskExecutor taskExecutor = context.getBean("clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class);
    assertThat(taskExecutor.getCorePoolSize()).isEqualTo(21);
    assertThat(taskExecutor.getMaxPoolSize()).isEqualTo(22);
    assertThat(taskExecutor.getKeepAliveSeconds()).isEqualTo(23);
    SimpleBrokerMessageHandler broker = context.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class);
    assertThat(broker.isPreservePublishOrder()).isTrue();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) AbstractSubscribableChannel(org.springframework.messaging.support.AbstractSubscribableChannel) SimpleBrokerMessageHandler(org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Test(org.junit.jupiter.api.Test)

Example 55 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.

the class OrderedMessageChannelDecoratorTests method setup.

@BeforeEach
public void setup() {
    this.executor = new ThreadPoolTaskExecutor();
    this.executor.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 2);
    this.executor.setAllowCoreThreadTimeOut(true);
    this.executor.afterPropertiesSet();
    this.channel = new ExecutorSubscribableChannel(this.executor);
    OrderedMessageChannelDecorator.configureInterceptor(this.channel, true);
    this.sender = new OrderedMessageChannelDecorator(this.channel, logger);
}
Also used : ExecutorSubscribableChannel(org.springframework.messaging.support.ExecutorSubscribableChannel) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)152 Bean (org.springframework.context.annotation.Bean)72 ExceptionHandlingAsyncTaskExecutor (io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor)19 Test (org.junit.jupiter.api.Test)19 BigInteger (java.math.BigInteger)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 RateLimiter (com.google.common.util.concurrent.RateLimiter)14 Test (org.junit.Test)14 Random (java.util.Random)12 ApplicationContext (org.springframework.context.ApplicationContext)12 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)9 Service (org.fisco.bcos.channel.client.Service)9 Credentials (org.fisco.bcos.web3j.crypto.Credentials)9 Web3j (org.fisco.bcos.web3j.protocol.Web3j)9 ChannelEthereumService (org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService)9 TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)9 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)9 CountDownLatch (java.util.concurrent.CountDownLatch)8 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)6 MDCCleanerTaskDecorator (com.sequenceiq.cloudbreak.concurrent.MDCCleanerTaskDecorator)4