Java Code Examples for org.flowable.engine.ProcessEngineConfiguration#getAsyncExecutor()

The following examples show how to use org.flowable.engine.ProcessEngineConfiguration#getAsyncExecutor() . 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: JobTestHelper.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static void executeJobExecutorForTime(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait, long intervalMillis) {
    AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor();
    asyncExecutor.start();

    try {
        Timer timer = new Timer();
        InterruptTask task = new InterruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        try {
            while (!task.isTimeLimitExceeded()) {
                Thread.sleep(intervalMillis);
            }
        } catch (InterruptedException e) {
            // ignore
        } finally {
            timer.cancel();
        }

    } finally {
        asyncExecutor.shutdown();
    }
}
 
Example 2
Source File: JobTestHelper.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static void executeJobExecutorForTime(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait, long intervalMillis) {
    AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor();
    asyncExecutor.start();

    try {
        Timer timer = new Timer();
        InterruptTask task = new InterruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        try {
            while (!task.isTimeLimitExceeded()) {
                Thread.sleep(intervalMillis);
            }
        } catch (InterruptedException e) {
            // ignore
        } finally {
            timer.cancel();
        }

    } finally {
        asyncExecutor.shutdown();
    }
}
 
Example 3
Source File: JobTestHelper.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public static void waitForJobExecutorToProcessAllJobs(ProcessEngineConfiguration processEngineConfiguration,
        ManagementService managementService, long maxMillisToWait, long intervalMillis, boolean shutdownExecutorWhenFinished) {

    AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor();
    asyncExecutor.start();

    try {
        Timer timer = new Timer();
        InterruptTask task = new InterruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        boolean areJobsAvailable = true;
        try {
            while (areJobsAvailable && !task.isTimeLimitExceeded()) {
                Thread.sleep(intervalMillis);
                try {
                    areJobsAvailable = areJobsAvailable(managementService);
                } catch (Throwable t) {
                    // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
                    // isolation level doesn't allow READ of the table
                }
            }
        } catch (InterruptedException e) {
            // ignore
        } finally {
            timer.cancel();
        }
        if (areJobsAvailable) {
            throw new FlowableException("time limit of " + maxMillisToWait + " was exceeded");
        }

    } finally {
        if (shutdownExecutorWhenFinished) {
            asyncExecutor.shutdown();
        }
    }
}
 
Example 4
Source File: JobTestHelper.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public static void waitForJobExecutorToProcessAllJobsAndExecutableTimerJobs(ProcessEngineConfiguration processEngineConfiguration, ManagementService managementService, long maxMillisToWait, long intervalMillis,
        boolean shutdownExecutorWhenFinished) {

    AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor();
    asyncExecutor.start();
    processEngineConfiguration.setAsyncExecutorActivate(true);

    try {
        Timer timer = new Timer();
        InterruptTask task = new InterruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        boolean areJobsAvailable = true;
        try {
            while (areJobsAvailable && !task.isTimeLimitExceeded()) {
                Thread.sleep(intervalMillis);
                try {
                    areJobsAvailable = areJobsOrExecutableTimersAvailable(managementService);
                } catch (Throwable t) {
                    // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
                    // isolation level doesn't allow READ of the table
                }
            }
        } catch (InterruptedException e) {
            // ignore
        } finally {
            timer.cancel();
        }
        if (areJobsAvailable) {
            throw new FlowableException("time limit of " + maxMillisToWait + " was exceeded");
        }

    } finally {
        if (shutdownExecutorWhenFinished) {
            processEngineConfiguration.setAsyncExecutorActivate(false);
            asyncExecutor.shutdown();
        }
    }
}
 
Example 5
Source File: JobTestHelper.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected static void internalWaitForJobs(ProcessEngineConfiguration processEngineConfiguration, ManagementService managementService,
    Predicate<ManagementService> jobsAvailablePredicate, long maxMillisToWait, long intervalMillis, boolean shutdownExecutorWhenFinished) {
    AsyncExecutor asyncExecutor = processEngineConfiguration.getAsyncExecutor();
    asyncExecutor.start();
    processEngineConfiguration.setAsyncExecutorActivate(true);

    try {
        Timer timer = new Timer();
        InterruptTask task = new InterruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        boolean areJobsAvailable = true;
        try {
            while (areJobsAvailable && !task.isTimeLimitExceeded()) {
                Thread.sleep(intervalMillis);
                try {
                    areJobsAvailable = jobsAvailablePredicate.test(managementService);
                } catch (Throwable t) {
                    // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
                    // isolation level doesn't allow READ of the table
                }
            }
        } catch (InterruptedException e) {
            // ignore
        } finally {
            timer.cancel();
        }
        if (areJobsAvailable) {
            throw new FlowableException("time limit of " + maxMillisToWait + " was exceeded");
        }

    } finally {
        if (shutdownExecutorWhenFinished) {
            processEngineConfiguration.setAsyncExecutorActivate(false);
            asyncExecutor.shutdown();
        }
    }
}
 
Example 6
Source File: JobExecutorMBean.java    From flowable-engine with Apache License 2.0 2 votes vote down vote up
public JobExecutorMBean(ProcessEngineConfiguration processEngineConfig) {
    jobExecutor = processEngineConfig.getAsyncExecutor();

}