Search in sources :

Example 1 with DefaultAsyncJobExecutor

use of org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method initAsyncExecutor.

// async executor /////////////////////////////////////////////////////////////
protected void initAsyncExecutor() {
    if (isAsyncExecutorEnabled()) {
        if (asyncExecutor == null) {
            DefaultAsyncJobExecutor defaultAsyncExecutor = new DefaultAsyncJobExecutor();
            // Thread pool config
            defaultAsyncExecutor.setCorePoolSize(asyncExecutorCorePoolSize);
            defaultAsyncExecutor.setMaxPoolSize(asyncExecutorMaxPoolSize);
            defaultAsyncExecutor.setKeepAliveTime(asyncExecutorThreadKeepAliveTime);
            // Threadpool queue
            if (asyncExecutorThreadPoolQueue != null) {
                defaultAsyncExecutor.setThreadPoolQueue(asyncExecutorThreadPoolQueue);
            }
            defaultAsyncExecutor.setQueueSize(asyncExecutorThreadPoolQueueSize);
            // Acquisition wait time
            defaultAsyncExecutor.setDefaultTimerJobAcquireWaitTimeInMillis(asyncExecutorDefaultTimerJobAcquireWaitTime);
            defaultAsyncExecutor.setDefaultAsyncJobAcquireWaitTimeInMillis(asyncExecutorDefaultAsyncJobAcquireWaitTime);
            // Queue full wait time
            defaultAsyncExecutor.setDefaultQueueSizeFullWaitTimeInMillis(asyncExecutorDefaultQueueSizeFullWaitTime);
            // Job locking
            defaultAsyncExecutor.setTimerLockTimeInMillis(asyncExecutorTimerLockTimeInMillis);
            defaultAsyncExecutor.setAsyncJobLockTimeInMillis(asyncExecutorAsyncJobLockTimeInMillis);
            if (asyncExecutorLockOwner != null) {
                defaultAsyncExecutor.setLockOwner(asyncExecutorLockOwner);
            }
            // Retry
            defaultAsyncExecutor.setRetryWaitTimeInMillis(asyncExecutorLockRetryWaitTimeInMillis);
            // Shutdown
            defaultAsyncExecutor.setSecondsToWaitOnShutdown(asyncExecutorSecondsToWaitOnShutdown);
            asyncExecutor = defaultAsyncExecutor;
        }
        asyncExecutor.setCommandExecutor(commandExecutor);
        asyncExecutor.setAutoActivate(asyncExecutorActivate);
    }
}
Also used : DefaultAsyncJobExecutor(org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor)

Example 2 with DefaultAsyncJobExecutor

use of org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor in project Activiti by Activiti.

the class ExecutorPerTenantAsyncExecutor method addTenantAsyncExecutor.

public void addTenantAsyncExecutor(String tenantId, boolean startExecutor) {
    AsyncExecutor tenantExecutor = null;
    if (tenantAwareAyncExecutorFactory == null) {
        tenantExecutor = new DefaultAsyncJobExecutor();
    } else {
        tenantExecutor = tenantAwareAyncExecutorFactory.createAsyncExecutor(tenantId);
    }
    if (tenantExecutor instanceof DefaultAsyncJobExecutor) {
        DefaultAsyncJobExecutor defaultAsyncJobExecutor = (DefaultAsyncJobExecutor) tenantExecutor;
        defaultAsyncJobExecutor.setAsyncJobsDueRunnable(new TenantAwareAcquireAsyncJobsDueRunnable(defaultAsyncJobExecutor, tenantInfoHolder, tenantId));
        defaultAsyncJobExecutor.setTimerJobRunnable(new TenantAwareAcquireTimerJobsRunnable(defaultAsyncJobExecutor, tenantInfoHolder, tenantId));
        defaultAsyncJobExecutor.setExecuteAsyncRunnableFactory(new TenantAwareExecuteAsyncRunnableFactory(tenantInfoHolder, tenantId));
    }
    // Needs to be done for job executors created after boot. Doesn't hurt on boot.
    tenantExecutor.setCommandExecutor(commandExecutor);
    tenantExecutors.put(tenantId, tenantExecutor);
    if (startExecutor) {
        tenantExecutor.start();
    }
}
Also used : AsyncExecutor(org.activiti.engine.impl.asyncexecutor.AsyncExecutor) DefaultAsyncJobExecutor(org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor)

Aggregations

DefaultAsyncJobExecutor (org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor)2 AsyncExecutor (org.activiti.engine.impl.asyncexecutor.AsyncExecutor)1