Class JobExecutorWaitUtils
java.lang.Object
org.operaton.bpm.engine.test.util.JobExecutorWaitUtils
Utility class for managing and ensuring the processing of jobs by the
JobExecutor
in a BPM execution environment. This class provides methods for waiting until
all jobs are processed, querying the availability of jobs, and waiting for jobs
running in the thread pool to finish execution.
The methods offered by this class facilitate coordination of job processing during tasks such as testing, ensuring proper job execution, and system synchronization.
Note that this class includes mechanisms for controlling the active state of the JobExecutor and employs configurable time intervals and timeouts for various operations. All methods are statically available since the class is not intended for instantiation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final long -
Method Summary
Modifier and TypeMethodDescriptionstatic voidwaitForCondition(Callable<Boolean> condition, long maxMillisToWait, long checkInterval) Waits for a specified condition to be met within a given time period, repeatedly checking the condition at specified intervals.static voidwaitForJobExecutionRunnablesToFinish(long maxMillisToWait, long intervalMillis, JobExecutor jobExecutor) Waits for all job execution runnables to finish within the specified maximum time, checking the status at regular intervals.static voidWaits for theJobExecutorto process all jobs within theprocess engine's default configuration using the default maximum wait time.static voidwaitForJobExecutorToProcessAllJobs(long maxMillisToWait) Waits for theJobExecutorto process all jobs within theprocess engine's default configuration for the specified maximum time.static voidwaitForJobExecutorToProcessAllJobs(long maxMillisToWait, long checkInterval, JobExecutor jobExecutor, ManagementService managementService) Waits for theJobExecutorto process all jobs within a specified maximum time, checking the job completion status at regular intervals.static voidwaitForJobExecutorToProcessAllJobs(String processInstanceId, long maxMillisToWait, long checkInterval, JobExecutor jobExecutor, ManagementService managementService) Waits for theJobExecutorto process all jobs associated with a specific process instance.static voidwaitForJobExecutorToProcessAllJobs(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait) Waits for theJobExecutorto process all jobs within the process engine configuration for the specified maximum time.static voidwaitForJobExecutorToProcessAllJobs(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait, long checkInterval) Waits for theJobExecutorto process all jobs within a specified maximum time, checking the job completion status at regular intervals.
-
Field Details
-
CHECK_INTERVAL_MS
public static final long CHECK_INTERVAL_MS- See Also:
-
JOBS_WAIT_TIMEOUT_MS
public static final long JOBS_WAIT_TIMEOUT_MS- See Also:
-
-
Method Details
-
waitForJobExecutorToProcessAllJobs
public static void waitForJobExecutorToProcessAllJobs()Waits for theJobExecutorto process all jobs within theprocess engine's default configuration using the default maximum wait time. This method internally delegates towaitForJobExecutorToProcessAllJobs(long)using a predefined timeout. -
waitForJobExecutorToProcessAllJobs
public static void waitForJobExecutorToProcessAllJobs(long maxMillisToWait) Waits for theJobExecutorto process all jobs within theprocess engine's default configuration for the specified maximum time. It retrieves the process engine configuration and delegates the waiting logic to an internal implementation.- Parameters:
maxMillisToWait- the maximum time in milliseconds to wait for all jobs to be processed
-
waitForJobExecutorToProcessAllJobs
public static void waitForJobExecutorToProcessAllJobs(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait) Waits for theJobExecutorto process all jobs within the process engine configuration for the specified maximum time. The method ensures that no jobs remain unprocessed within the given time frame by invoking an internal implementation with a default check interval.- Parameters:
processEngineConfiguration- the process engine configuration providing access to theJobExecutorandManagementServicemaxMillisToWait- the maximum time in milliseconds to wait for all jobs to be processed
-
waitForJobExecutorToProcessAllJobs
public static void waitForJobExecutorToProcessAllJobs(ProcessEngineConfiguration processEngineConfiguration, long maxMillisToWait, long checkInterval) Waits for theJobExecutorto process all jobs within a specified maximum time, checking the job completion status at regular intervals. If the jobs are not processed within the specified time limit, aProcessEngineExceptionis thrown. Optionally shuts down the job executor after processing jobs.- Parameters:
processEngineConfiguration- the process engine configuration providing access to theJobExecutorandManagementServicemaxMillisToWait- the maximum time in milliseconds to wait for all jobs to be processedcheckInterval- the time interval in milliseconds to check for job completion
-
waitForJobExecutorToProcessAllJobs
public static void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long checkInterval, JobExecutor jobExecutor, ManagementService managementService) Waits for theJobExecutorto process all jobs within a specified maximum time, checking the job completion status at regular intervals. If the jobs are not processed within the specified time limit, aProcessEngineExceptionis thrown. Optionally shuts down the job executor after processing jobs.- Parameters:
maxMillisToWait- the maximum time in milliseconds to wait for all jobs to be processedcheckInterval- the time interval in milliseconds to check for job completionjobExecutor- theJobExecutorresponsible for managing job executionmanagementService- theManagementServiceused to query and manage jobs
-
waitForJobExecutorToProcessAllJobs
public static void waitForJobExecutorToProcessAllJobs(String processInstanceId, long maxMillisToWait, long checkInterval, JobExecutor jobExecutor, ManagementService managementService) Waits for theJobExecutorto process all jobs associated with a specific process instance. This method repeatedly checks for job completion at specified intervals within a defined maximum wait time. Throws aProcessEngineExceptionin case the timeout is exceeded. Optionally shuts down theJobExecutorafter processing if specified.- Parameters:
processInstanceId- the ID of the process instance for which jobs need to be processedmaxMillisToWait- the maximum time in milliseconds to wait for all jobs to be processedcheckInterval- the interval in milliseconds to check for job completionjobExecutor- theJobExecutorresponsible for processing the jobsmanagementService- theManagementServiceused to interact with jobs management
-
waitForJobExecutionRunnablesToFinish
public static void waitForJobExecutionRunnablesToFinish(long maxMillisToWait, long intervalMillis, JobExecutor jobExecutor) Waits for all job execution runnables to finish within the specified maximum time, checking the status at regular intervals.- Parameters:
maxMillisToWait- the maximum time in milliseconds to wait for the job execution runnables to completeintervalMillis- the interval in milliseconds at which to check whether the job execution runnables have finishedjobExecutor- theJobExecutorresponsible for managing the job execution runnables
-
waitForCondition
public static void waitForCondition(Callable<Boolean> condition, long maxMillisToWait, long checkInterval) Waits for a specified condition to be met within a given time period, repeatedly checking the condition at specified intervals. If the condition is not met within the time limit, aProcessEngineExceptionis thrown.- Parameters:
condition- ACallablereturning aBoolean, representing the condition to be evaluated. The method will wait until this condition evaluates totrue.maxMillisToWait- The maximum amount of time in milliseconds to wait for the condition to be satisfied.checkInterval- The interval in milliseconds at which the condition will be re-evaluated. If this value is greater thanmaxMillisToWait, it will be adjusted to matchmaxMillisToWait.
-