org.springframework.scheduling.concurrent.ConcurrentTaskExecutor Java Examples
The following examples show how to use
org.springframework.scheduling.concurrent.ConcurrentTaskExecutor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #2
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #3
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #4
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #5
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #6
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #7
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #8
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #9
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #10
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #11
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #12
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #13
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #14
Source File: BatchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") public TaskExecutor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #15
Source File: SpringAsynchConfig.java From Spring-5.0-Cookbook with MIT License | 6 votes |
@Bean("mvcTaskexecutor") @Override public Executor getAsyncExecutor() { ConcurrentTaskExecutor executor = new ConcurrentTaskExecutor( Executors.newFixedThreadPool(100)); executor.setTaskDecorator(new TaskDecorator() { @Override public Runnable decorate (Runnable runnable) { return () -> { long t = System.currentTimeMillis(); runnable.run(); logger.info("creating ConcurrentTaskExecutor thread pool...."); System.out.printf("Thread %s has a processing time: %s%n", Thread.currentThread().getName(), (System.currentTimeMillis() - t)); }; } }); return executor; }
Example #16
Source File: MvcNamespaceTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testAsyncSupportOptions() throws Exception { loadBeanDefinitions("mvc-config-async-support.xml"); RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class); assertNotNull(adapter); DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter); assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass()); assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout")); CallableProcessingInterceptor[] callableInterceptors = (CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors"); assertEquals(1, callableInterceptors.length); DeferredResultProcessingInterceptor[] deferredResultInterceptors = (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors"); assertEquals(1, deferredResultInterceptors.length); }
Example #17
Source File: MvcNamespaceTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testAsyncSupportOptions() throws Exception { loadBeanDefinitions("mvc-config-async-support.xml", 15); RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class); assertNotNull(adapter); DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter); assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass()); assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout")); CallableProcessingInterceptor[] callableInterceptors = (CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors"); assertEquals(1, callableInterceptors.length); DeferredResultProcessingInterceptor[] deferredResultInterceptors = (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors"); assertEquals(1, deferredResultInterceptors.length); }
Example #18
Source File: MvcNamespaceTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testAsyncSupportOptions() throws Exception { loadBeanDefinitions("mvc-config-async-support.xml"); RequestMappingHandlerAdapter adapter = appContext.getBean(RequestMappingHandlerAdapter.class); assertNotNull(adapter); DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter); assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass()); assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout")); CallableProcessingInterceptor[] callableInterceptors = (CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors"); assertEquals(1, callableInterceptors.length); DeferredResultProcessingInterceptor[] deferredResultInterceptors = (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors"); assertEquals(1, deferredResultInterceptors.length); }
Example #19
Source File: TaskJobLauncherCommandLineRunnerTests.java From spring-cloud-task with Apache License 2.0 | 5 votes |
protected JobLauncher createJobLauncher() throws Exception { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(getJobRepository()); jobLauncher.setTaskExecutor(new ConcurrentTaskExecutor()); jobLauncher.afterPropertiesSet(); return jobLauncher; }
Example #20
Source File: PetClinicApplication.java From spring-init with Apache License 2.0 | 5 votes |
@Bean public EntityManagerFactoryBuilderCustomizer customEntityManagerFactoryBootstrapExecutorCustomizer( Map<String, AsyncTaskExecutor> taskExecutors) { return (builder) -> { builder.setBootstrapExecutor(new ConcurrentTaskExecutor()); }; }
Example #21
Source File: WebMvcConfigurationSupportExtensionTests.java From spring-analysis-note with MIT License | 5 votes |
@Override public void configureAsyncSupport(AsyncSupportConfigurer configurer) { configurer.setDefaultTimeout(2500).setTaskExecutor(new ConcurrentTaskExecutor()) .registerCallableInterceptors(new CallableProcessingInterceptor() { }) .registerDeferredResultInterceptors(new DeferredResultProcessingInterceptor() { }); }
Example #22
Source File: AdHocBatchConfig.java From spring-batch-rest with Apache License 2.0 | 4 votes |
public JobLauncher getJobLauncher() { SimpleJobLauncher jobLauncher = new SimpleJobLauncher(); jobLauncher.setJobRepository(jobRepository); jobLauncher.setTaskExecutor(new ConcurrentTaskExecutor(executorService)); return jobLauncher; }
Example #23
Source File: SpringBootAdminServer.java From Cleanstone with MIT License | 4 votes |
@Override public void configureAsyncSupport(AsyncSupportConfigurer configurer) { configurer.setTaskExecutor(new ConcurrentTaskExecutor(Executors.newFixedThreadPool(5))); }
Example #24
Source File: WebMvcConfigurationSupportExtensionTests.java From java-technology-stack with MIT License | 4 votes |
@Override public void configureAsyncSupport(AsyncSupportConfigurer configurer) { configurer.setDefaultTimeout(2500).setTaskExecutor(new ConcurrentTaskExecutor()) .registerCallableInterceptors(new CallableProcessingInterceptor() { }) .registerDeferredResultInterceptors(new DeferredResultProcessingInterceptor() {}); }
Example #25
Source File: WebMvcConfigurationSupportExtensionTests.java From java-technology-stack with MIT License | 4 votes |
@SuppressWarnings("unchecked") @Test public void requestMappingHandlerAdapter() throws Exception { RequestMappingHandlerAdapter adapter = this.config.requestMappingHandlerAdapter(); // ConversionService String actual = this.config.mvcConversionService().convert(new TestBean(), String.class); assertEquals("converted", actual); // Message converters List<HttpMessageConverter<?>> converters = adapter.getMessageConverters(); assertEquals(2, converters.size()); assertEquals(StringHttpMessageConverter.class, converters.get(0).getClass()); assertEquals(MappingJackson2HttpMessageConverter.class, converters.get(1).getClass()); ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter) converters.get(1)).getObjectMapper(); assertFalse(objectMapper.getDeserializationConfig().isEnabled(DEFAULT_VIEW_INCLUSION)); assertFalse(objectMapper.getSerializationConfig().isEnabled(DEFAULT_VIEW_INCLUSION)); assertFalse(objectMapper.getDeserializationConfig().isEnabled(FAIL_ON_UNKNOWN_PROPERTIES)); DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter); // Custom argument resolvers and return value handlers List<HandlerMethodArgumentResolver> argResolvers = (List<HandlerMethodArgumentResolver>) fieldAccessor.getPropertyValue("customArgumentResolvers"); assertEquals(1, argResolvers.size()); List<HandlerMethodReturnValueHandler> handlers = (List<HandlerMethodReturnValueHandler>) fieldAccessor.getPropertyValue("customReturnValueHandlers"); assertEquals(1, handlers.size()); // Async support options assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass()); assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout")); CallableProcessingInterceptor[] callableInterceptors = (CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors"); assertEquals(1, callableInterceptors.length); DeferredResultProcessingInterceptor[] deferredResultInterceptors = (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors"); assertEquals(1, deferredResultInterceptors.length); assertEquals(false, fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect")); }
Example #26
Source File: WebMvcConfigurationSupportExtensionTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Test public void requestMappingHandlerAdapter() throws Exception { RequestMappingHandlerAdapter adapter = this.config.requestMappingHandlerAdapter(); // ConversionService String actual = this.config.mvcConversionService().convert(new TestBean(), String.class); assertEquals("converted", actual); // Message converters assertEquals(2, adapter.getMessageConverters().size()); assertEquals(StringHttpMessageConverter.class, adapter.getMessageConverters().get(0).getClass()); assertEquals(MappingJackson2HttpMessageConverter.class, adapter.getMessageConverters().get(1).getClass()); ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter)adapter.getMessageConverters().get(1)).getObjectMapper(); assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)); assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)); assertFalse(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)); DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(adapter); // Custom argument resolvers and return value handlers List<HandlerMethodArgumentResolver> argResolvers = (List<HandlerMethodArgumentResolver>) fieldAccessor.getPropertyValue("customArgumentResolvers"); assertEquals(1, argResolvers.size()); List<HandlerMethodReturnValueHandler> handlers = (List<HandlerMethodReturnValueHandler>) fieldAccessor.getPropertyValue("customReturnValueHandlers"); assertEquals(1, handlers.size()); // Async support options assertEquals(ConcurrentTaskExecutor.class, fieldAccessor.getPropertyValue("taskExecutor").getClass()); assertEquals(2500L, fieldAccessor.getPropertyValue("asyncRequestTimeout")); CallableProcessingInterceptor[] callableInterceptors = (CallableProcessingInterceptor[]) fieldAccessor.getPropertyValue("callableInterceptors"); assertEquals(1, callableInterceptors.length); DeferredResultProcessingInterceptor[] deferredResultInterceptors = (DeferredResultProcessingInterceptor[]) fieldAccessor.getPropertyValue("deferredResultInterceptors"); assertEquals(1, deferredResultInterceptors.length); assertEquals(false, fieldAccessor.getPropertyValue("ignoreDefaultModelOnRedirect")); }
Example #27
Source File: WebMvcConfigurationSupportExtensionTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void configureAsyncSupport(AsyncSupportConfigurer configurer) { configurer.setDefaultTimeout(2500).setTaskExecutor(new ConcurrentTaskExecutor()) .registerCallableInterceptors(new CallableProcessingInterceptorAdapter() { }) .registerDeferredResultInterceptors(new DeferredResultProcessingInterceptorAdapter() {}); }
Example #28
Source File: ExecutorAutoConfiguration.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
/** * @return {@link TaskExecutor} for task execution */ @Bean @ConditionalOnMissingBean public TaskExecutor taskExecutor() { return new ConcurrentTaskExecutor(asyncExecutor()); }
Example #29
Source File: AmqpTestConfiguration.java From hawkbit with Eclipse Public License 1.0 | 4 votes |
@Bean TaskExecutor taskExecutor() { return new ConcurrentTaskExecutor(asyncExecutor()); }
Example #30
Source File: CoderadarTestApplication.java From coderadar with MIT License | 4 votes |
@Bean public AsyncListenableTaskExecutor taskExecutor() { return new ConcurrentTaskExecutor(Runnable::run); }