use of org.activiti.spring.SpringAsyncExecutor in project herd by FINRAOS.
the class ServiceSpringModuleConfig method activitiAsyncExecutor.
/**
* Returns an Activiti Async executor that uses our configured task executor.
*
* @param activitiTaskExecutor the task executor. Note that the parameter must be named as is so that Spring IoC knows which TaskExecutor bean to autowire.
* @param springRejectedJobsHandler The Spring rejected jobs handler
*
* @return the Async executor.
*/
@Bean
public AsyncExecutor activitiAsyncExecutor(TaskExecutor activitiTaskExecutor, SpringRejectedJobsHandler springRejectedJobsHandler) {
SpringAsyncExecutor activitiAsyncExecutor = new SpringAsyncExecutor(activitiTaskExecutor, springRejectedJobsHandler);
activitiAsyncExecutor.setAsyncJobLockTimeInMillis(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_ASYNC_JOB_LOCK_TIME_MILLIS, Integer.class));
return activitiAsyncExecutor;
}
use of org.activiti.spring.SpringAsyncExecutor in project herd by FINRAOS.
the class ActivitiProcessEngineConfigurationTest method testActivitiThreadPoolIsIsolatedFromGenericAsyncPool.
/**
* Ensure that the Activiti's thread pool is separate from the application's generic thread pool.
*/
@Test
public void testActivitiThreadPoolIsIsolatedFromGenericAsyncPool() {
AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor();
SpringAsyncExecutor springAsyncExecutor = (SpringAsyncExecutor) asyncExecutor;
TaskExecutor taskExecutor = springAsyncExecutor.getTaskExecutor();
assertTrue(genericTaskExecutor != taskExecutor);
}
use of org.activiti.spring.SpringAsyncExecutor in project herd by FINRAOS.
the class ActivitiProcessEngineConfigurationTest method testActivitiThreadPoolUsesConfiguredValues.
/**
* Ensure that the Activiti's thread pool uses the correct configuration value.
*
* This assertion is limited in that the configuration values must be set before Spring application context is initialized, which we cannot control easily
* in unit test.
*/
@Test
public void testActivitiThreadPoolUsesConfiguredValues() {
AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor();
SpringAsyncExecutor springAsyncExecutor = (SpringAsyncExecutor) asyncExecutor;
TaskExecutor taskExecutor = springAsyncExecutor.getTaskExecutor();
ThreadPoolTaskExecutor threadPoolTaskExecutor = (ThreadPoolTaskExecutor) taskExecutor;
Integer corePoolSize = threadPoolTaskExecutor.getCorePoolSize();
Integer maxPoolSize = threadPoolTaskExecutor.getMaxPoolSize();
Integer keepAliveSeconds = threadPoolTaskExecutor.getKeepAliveSeconds();
// No real easy way of getting the queue capacity from the already constructed thread pool
Integer remainingCapacity = ((LinkedBlockingQueue<?>) threadPoolTaskExecutor.getThreadPoolExecutor().getQueue()).remainingCapacity();
assertEquals(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_THREAD_POOL_CORE_POOL_SIZE, Integer.class), corePoolSize);
assertEquals(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_THREAD_POOL_MAX_POOL_SIZE, Integer.class), maxPoolSize);
assertEquals(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_THREAD_POOL_KEEP_ALIVE_SECS, Integer.class), keepAliveSeconds);
assertEquals(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_THREAD_POOL_QUEUE_CAPACITY, Integer.class), remainingCapacity);
}
Aggregations