Search in sources :

Example 21 with ThreadPoolTaskExecutor

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

the class MessageBrokerConfigurationTests method brokerChannelCustomized.

@Test
public void brokerChannelCustomized() {
    AbstractSubscribableChannel channel = this.customContext.getBean("brokerChannel", AbstractSubscribableChannel.class);
    assertEquals(4, channel.getInterceptors().size());
    ThreadPoolTaskExecutor taskExecutor = this.customContext.getBean("brokerChannelExecutor", ThreadPoolTaskExecutor.class);
    assertEquals(31, taskExecutor.getCorePoolSize());
    assertEquals(32, taskExecutor.getMaxPoolSize());
    assertEquals(33, taskExecutor.getKeepAliveSeconds());
}
Also used : AbstractSubscribableChannel(org.springframework.messaging.support.AbstractSubscribableChannel) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Test(org.junit.Test)

Example 22 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project metacat by Netflix.

the class CommonServerConfig method taskExecutor.

/**
     * Get a task executor for executing tasks asynchronously that don't need to be scheduled at a recurring rate.
     *
     * @param metacatProperties The metacat properties to get number of executor threads from.
     *                          Likely best to do one more than number of CPUs
     * @return The task executor the system to use
     */
@Bean
public AsyncTaskExecutor taskExecutor(final MetacatProperties metacatProperties) {
    final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(metacatProperties.getEvent().getBus().getExecutor().getThread().getCount());
    return executor;
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Bean(org.springframework.context.annotation.Bean)

Example 23 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project Settler by EmhyrVarEmreis.

the class AsyncConfiguration method getAsyncExecutor.

@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
    log.debug("Creating Async Task Executor");
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setCorePoolSize(settlerProperties.getAsync().getCorePoolSize());
    executor.setMaxPoolSize(settlerProperties.getAsync().getMaxPoolSize());
    executor.setQueueCapacity(settlerProperties.getAsync().getQueueCapacity());
    executor.setThreadNamePrefix("settler-Executor-");
    return new ExceptionHandlingAsyncTaskExecutor(executor);
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) ExceptionHandlingAsyncTaskExecutor(pl.morecraft.dev.settler.configuration.util.ExceptionHandlingAsyncTaskExecutor) Bean(org.springframework.context.annotation.Bean)

Example 24 with ThreadPoolTaskExecutor

use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project ocvn by devgateway.

the class AsyncConfiguration method getAsyncExecutor.

@Bean
@Override
public ThreadPoolTaskExecutor getAsyncExecutor() {
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setMaxPoolSize(1);
    taskExecutor.setThreadNamePrefix("VNImportServiceExecutor-");
    return taskExecutor;
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Bean(org.springframework.context.annotation.Bean)

Aggregations

ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)24 Test (org.junit.Test)8 Bean (org.springframework.context.annotation.Bean)8 Random (java.util.Random)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 AbstractSubscribableChannel (org.springframework.messaging.support.AbstractSubscribableChannel)2 Brave (com.github.kristofa.brave.Brave)1 ServerSpan (com.github.kristofa.brave.ServerSpan)1 ServerSpanState (com.github.kristofa.brave.ServerSpanState)1 Endpoint (com.twitter.zipkin.gen.Endpoint)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ByteBuffer (java.nio.ByteBuffer)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Executor (java.util.concurrent.Executor)1 FutureTask (java.util.concurrent.FutureTask)1 CamelThreadFactory (org.apache.camel.util.concurrent.CamelThreadFactory)1 ExecuteContext (org.jooq.ExecuteContext)1 ExecuteListenerProvider (org.jooq.ExecuteListenerProvider)1