org.openbp.config.engine.EngineRunnerConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openbp-server Show documentation
Show all versions of openbp-server Show documentation
The OpenBP process engine (main module)
package org.openbp.config.engine;
import org.openbp.server.engine.EngineRunner;
import org.openbp.server.engine.ThreadPoolEngineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* Spring configuration providing a thread pool-based process execution.
* The default size of the thread pool is 10.
* The default idle time for queries for pending tasks is 200 ms, i. e. the engine will check each 200 ms for tasks awaiting execution.
*/
@Configuration
public class EngineRunnerConfig
{
/** Time in milliseconds between queries for pending tokens */
private int idleTime = 200;
/** Max. number of concurrent engine threads */
private int threadPoolSize = 10;
@Bean
public EngineRunner engineRunner()
{
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(threadPoolSize);
executor.setMaxPoolSize(threadPoolSize);
executor.setQueueCapacity(0);
ThreadPoolEngineRunner runner = new ThreadPoolEngineRunner();
runner.setIdleTime(idleTime);
runner.setFetchSize(threadPoolSize);
runner.setExecutor(executor);
return runner;
}
/**
* Sets the time in milliseconds between queries for pending tokens.
*/
public void setIdleTime(int idleTime)
{
this.idleTime = idleTime;
}
/**
* Sets the max. number of concurrent engine threads.
*/
public void setThreadPoolSize(int threadPoolSize)
{
this.threadPoolSize = threadPoolSize;
}
}