All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openbp.config.engine.EngineRunnerConfig Maven / Gradle / Ivy

There is a newer version: 0.9.11
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy