List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor initialize
public void initialize()
From source file:org.homiefund.config.ApplicationConfiguration.java
@Override public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(4);/* w w w . j a v a 2 s . c om*/ executor.setMaxPoolSize(42); executor.setQueueCapacity(12); executor.setThreadNamePrefix("HomieExecutor-"); executor.initialize(); return executor; }
From source file:kymr.github.io.future.FutureSpringApplication.java
@Bean ThreadPoolTaskExecutor tp() {/*from www . ja v a2 s. c om*/ ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor(); te.setCorePoolSize(10); // default core thread pool te.setQueueCapacity(200); te.setMaxPoolSize(100); // after core pool is full -> after queue capacity (generally, unlimited) is full -> then, max pool size works. te.setThreadNamePrefix("mythread"); te.initialize(); //te.setAllowCoreThreadTimeOut(); //te.getKeepAliveSeconds() //te.setTaskDecorator(); // for task monitoring return te; }
From source file:org.elasticsoftware.elasticactors.configuration.AppConfiguration.java
@Bean(name = "asyncExecutor") public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(Runtime.getRuntime().availableProcessors()); executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors() * 3); executor.setQueueCapacity(1024);/*w w w .j av a 2 s . c o m*/ executor.setThreadNamePrefix("ASYNCHRONOUS-ANNOTATION-EXECUTOR-"); executor.initialize(); return executor; }
From source file:dk.clanie.actor.ActorAnnotationBeanPostProcessor.java
public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean instanceof AopInfrastructureBean) { // Ignore AOP infrastructure such as scoped proxies. return bean; }//from w w w. java 2s . co m Class<?> targetClass = AopUtils.getTargetClass(bean); Actor annotation = AnnotationUtils.findAnnotation(targetClass, Actor.class); if (annotation != null) { // if (AopUtils.canApply(this.asyncAnnotationAdvisor, targetClass)) { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setMaxPoolSize(1); executor.setDaemon(true); String threadNamePrefix = beanName + ","; executor.setThreadNamePrefix(threadNamePrefix); executor.initialize(); ActorAnnotationAdvisor actorAnnotationAdvisor = new ActorAnnotationAdvisor(executor); if (bean instanceof Advised) { ((Advised) bean).addAdvisor(0, actorAnnotationAdvisor); return bean; } else { ProxyFactory proxyFactory = new ProxyFactory(bean); // Copy our properties (proxyTargetClass etc) inherited from ProxyConfig. proxyFactory.copyFrom(this); proxyFactory.addAdvisor(actorAnnotationAdvisor); return proxyFactory.getProxy(this.beanClassLoader); } } else { // No async proxy needed. return bean; } }
From source file:access.Application.java
@Override @Bean//from www. j a v a 2s . c om public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(threadCountSize); executor.setMaxPoolSize(threadCountLimit); executor.initialize(); return executor; }
From source file:nl.pinniq.web.config.WebMvcConfiguration.java
@Bean public ThreadPoolTaskExecutor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(5);/*from www. ja v a 2s .c om*/ executor.setBeanName("threadPoolTaskExecutor"); executor.setMaxPoolSize(50); executor.setQueueCapacity(10); executor.setThreadNamePrefix("MyExecutor-"); executor.initialize(); return executor; }
From source file:org.elasticsoftware.elasticactors.examples.springweb.config.ApplicationContextConfiguration.java
@Bean(name = "asyncExecutor") public java.util.concurrent.Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(Runtime.getRuntime().availableProcessors()); executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors() * 3); executor.setQueueCapacity(1024);/*from www. j av a 2 s. c o m*/ executor.setThreadNamePrefix("ASYNCHRONOUS-ANNOTATION-EXECUTOR-"); executor.initialize(); return executor; }
From source file:com.bt.aloha.call.MaxCallDurationTerminationTest.java
@Test public void testInitializeWithOneTermination() { // setup//from w ww . j ava 2s . c o m ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor(); te.initialize(); maxCallDurationTermination.setTaskExecutor(te); callInfo = new CallInfo("test", CALL_ID_SET_TO_TERMINATE_IN_PAST, "1", "2", AutoTerminateAction.False, 1); if (!callInfo.setStartTime(System.currentTimeMillis() - FIVE_MINUTES_IN_MILLISECONDS)) throw new RuntimeException("Can't set time in the past for some reason"); callInfo.setCallState(CallState.Connected); callCollection.add(callInfo); maxCallDurationTermination.setCallBean(callBean); // act maxCallDurationTermination.runTask(); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } // allow time for thread to run // assert assertTrue(terminateWithReason); }
From source file:org.bremersee.common.spring.autoconfigure.SchedulingAutoConfiguration.java
@Bean(name = { "taskExecutor", "metricsExecutor" }) @Primary//from w w w .j av a 2s . c o m public Executor taskExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(properties.getTaskExecutorCorePoolSize()); executor.setMaxPoolSize(properties.getTaskExecutorMaxPoolSize()); executor.setQueueCapacity(properties.getTaskExecutorQueueCapacity()); executor.setThreadNamePrefix(properties.getTaskExecutorThreadNamePrefix()); executor.initialize(); return executor; }
From source file:org.red5.client.net.rtmp.RTMPConnManager.java
/** * Creates a connection instance based on the supplied type. * /*from www . j a va 2s .c o m*/ * @param cls * @return connection * @throws Exception */ public RTMPConnection createConnectionInstance(Class<?> cls) throws Exception { RTMPConnection conn = null; if (cls == RTMPMinaConnection.class) { conn = (RTMPMinaConnection) cls.newInstance(); } else if (cls == RTMPTClientConnection.class) { conn = (RTMPTClientConnection) cls.newInstance(); } else { conn = (RTMPConnection) cls.newInstance(); } conn.setMaxHandshakeTimeout(maxHandshakeTimeout); conn.setMaxInactivity(maxInactivity); conn.setPingInterval(pingInterval); // setup executor ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(1); executor.setDaemon(true); executor.setMaxPoolSize(1); executor.setQueueCapacity(executorQueueCapacity); executor.initialize(); conn.setExecutor(executor); return conn; }