List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor ThreadPoolTaskExecutor
ThreadPoolTaskExecutor
From source file:org.mimacom.sample.integration.patterns.user.service.integration.AsyncSearchServiceIntegration.java
private static AsyncRestTemplate initializeRestTemplate() { ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); threadPoolTaskExecutor.setCorePoolSize(2); threadPoolTaskExecutor.setMaxPoolSize(2); threadPoolTaskExecutor.setThreadNamePrefix("SearchServiceIntegration-"); threadPoolTaskExecutor.afterPropertiesSet(); return new AsyncRestTemplate(threadPoolTaskExecutor); }
From source file:com.epam.ta.reportportal.core.configs.JobsConfiguration.java
@Bean(name = "autoAnalyzeTaskExecutor") public TaskExecutor autoAnalyzeTaskExecutor() { final ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); threadPoolTaskExecutor.setCorePoolSize(10); threadPoolTaskExecutor.setMaxPoolSize(30); threadPoolTaskExecutor.setQueueCapacity(200); threadPoolTaskExecutor.setAllowCoreThreadTimeOut(true); threadPoolTaskExecutor.setThreadNamePrefix("auto-analyze-exec"); return threadPoolTaskExecutor; }
From source file:burstcoin.jminer.core.CoreConfig.java
/** * Round pool./*from ww w.j a va2s . co m*/ * * @return the thread pool task executor */ @Bean(name = "roundPool") public ThreadPoolTaskExecutor roundPool() { return new ThreadPoolTaskExecutor(); }
From source file:com.vmware.bdd.service.resmgmt.impl.VcInventorySyncService.java
public VcInventorySyncService() { ThreadPoolConfig config = new ThreadPoolConfig( Configuration.getThreadConfig(Constants.VCINVENTORYREFRESH_THREADPOOL_CONFIG, DEFAULT_VALUE)); LOGGER.debug(config.toString());//from w ww . j a v a2s. com es = new ThreadPoolTaskExecutor(); es.setCorePoolSize(config.getCorePoolSize()); es.setMaxPoolSize(config.getMaxPoolSize()); es.setQueueCapacity(config.getWorkQueue()); es.setThreadNamePrefix(NAME_PREFIX); es.initialize(); }
From source file:ru.xxlabaza.test.batch.job.MyJobBatchConfiguration.java
@Bean protected ThreadPoolTaskExecutor taskExecutor() { val executor = new ThreadPoolTaskExecutor(); executor.setThreadNamePrefix("task-executor-thread-"); executor.setCorePoolSize(appProperties.getBatch().getMyJob().getThreads()); return executor; }
From source file:org.mimacom.sample.integration.patterns.user.service.integration.BulkHeadedSearchServiceIntegration.java
private static AsyncRestTemplate initializeRestTemplate(String threadNamePrefix) { ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); threadPoolTaskExecutor.setCorePoolSize(2); threadPoolTaskExecutor.setMaxPoolSize(2); threadPoolTaskExecutor.setThreadNamePrefix(threadNamePrefix); threadPoolTaskExecutor.afterPropertiesSet(); return new AsyncRestTemplate(threadPoolTaskExecutor); }
From source file:py.una.pol.karaku.configuration.AsyncConfiguration.java
/** * Crea un nuevo executor. Vase {@link #getAsyncExecutor()} * * @return {@link Executor} de tareas asncronas * @see <a href="http://appcia.cnc.una.py/wf/index.php/Asyn_task">Wiki</a> *//*from ww w . ja v a 2 s. c o m*/ @Bean public AsyncTaskExecutor asyncExecutor() { final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(getInt("karaku.async.pool.size", DEFAULT_CORE_POOL_SIZE)); executor.setMaxPoolSize(getInt("karaku.async.pool.max_size", DEFAULT_CORE_POOL_MAX_SIZE)); executor.setQueueCapacity(getInt("karaku.async.queue.size", DEFAULT_ASYNC_QUEUE_SIZE)); executor.setThreadNamePrefix(properties.get("karaku.async.thread.prefix", DEFAULT_THREAD_PREFIX)); // TODO cambiar por un SyncTaskExecutor return executor; }
From source file:org.calrissian.mango.jms.stream.JmsFileTransferSupportTest.java
public void testFullCycle() throws Exception { try {/* w w w .j ava 2 s. co m*/ URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() { @Override public URLStreamHandler createURLStreamHandler(String protocol) { if ("testprot".equals(protocol)) return new URLStreamHandler() { @Override protected URLConnection openConnection(URL u) throws IOException { return new URLConnection(u) { @Override public void connect() throws IOException { } @Override public InputStream getInputStream() throws IOException { return new ByteArrayInputStream(TEST_STR.getBytes()); } @Override public String getContentType() { return "content/notnull"; } }; } }; return null; } }); } catch (Error ignored) { } final ActiveMQTopic ft = new ActiveMQTopic("testFileTransfer"); ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor(); te.initialize(); JmsFileSenderListener listener = new JmsFileSenderListener(); final String hashAlgorithm = "MD5"; listener.setHashAlgorithm(hashAlgorithm); listener.setStreamRequestDestination(ft); listener.setPieceSize(9); listener.setTaskExecutor(te); ConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); cf = new SingleTopicConnectionFactory(cf, "test"); JmsTemplate jmsTemplate = new JmsTemplate(); jmsTemplate.setConnectionFactory(cf); jmsTemplate.setReceiveTimeout(60000); listener.setJmsTemplate(jmsTemplate); Connection conn = cf.createConnection(); conn.start(); Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = sess.createConsumer(ft); consumer.setMessageListener(listener); JmsFileReceiver receiver = new JmsFileReceiver(); receiver.setHashAlgorithm(hashAlgorithm); receiver.setStreamRequestDestination(ft); receiver.setJmsTemplate(jmsTemplate); receiver.setPieceSize(9); JmsFileReceiverInputStream stream = (JmsFileReceiverInputStream) receiver.receiveStream("testprot:test"); StringBuilder buffer = new StringBuilder(); int read; while ((read = stream.read()) >= 0) { buffer.append((char) read); } stream.close(); assertEquals(TEST_STR, buffer.toString()); conn.stop(); }
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 w w w .ja v a 2s . c om 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 www .j a va 2 s .c o 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; } }