Class JobExecutorWaitUtils

java.lang.Object
org.operaton.bpm.engine.test.util.JobExecutorWaitUtils

public final class JobExecutorWaitUtils extends Object
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 Details

  • Method Details

    • waitForJobExecutorToProcessAllJobs

      public static void waitForJobExecutorToProcessAllJobs()
      Waits for the JobExecutor to process all jobs within the process engine's default configuration using the default maximum wait time. This method internally delegates to waitForJobExecutorToProcessAllJobs(long) using a predefined timeout.
    • waitForJobExecutorToProcessAllJobs

      public static void waitForJobExecutorToProcessAllJobs(long maxMillisToWait)
      Waits for the JobExecutor to process all jobs within the process 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 the JobExecutor to 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 the JobExecutor and ManagementService
      maxMillisToWait - 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 the JobExecutor to 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, a ProcessEngineException is thrown. Optionally shuts down the job executor after processing jobs.
      Parameters:
      processEngineConfiguration - the process engine configuration providing access to the JobExecutor and ManagementService
      maxMillisToWait - the maximum time in milliseconds to wait for all jobs to be processed
      checkInterval - 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 the JobExecutor to 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, a ProcessEngineException is thrown. Optionally shuts down the job executor after processing jobs.
      Parameters:
      maxMillisToWait - the maximum time in milliseconds to wait for all jobs to be processed
      checkInterval - the time interval in milliseconds to check for job completion
      jobExecutor - the JobExecutor responsible for managing job execution
      managementService - the ManagementService used to query and manage jobs
    • waitForJobExecutorToProcessAllJobs

      public static void waitForJobExecutorToProcessAllJobs(String processInstanceId, long maxMillisToWait, long checkInterval, JobExecutor jobExecutor, ManagementService managementService)
      Waits for the JobExecutor to 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 a ProcessEngineException in case the timeout is exceeded. Optionally shuts down the JobExecutor after processing if specified.
      Parameters:
      processInstanceId - the ID of the process instance for which jobs need to be processed
      maxMillisToWait - the maximum time in milliseconds to wait for all jobs to be processed
      checkInterval - the interval in milliseconds to check for job completion
      jobExecutor - the JobExecutor responsible for processing the jobs
      managementService - the ManagementService used 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 complete
      intervalMillis - the interval in milliseconds at which to check whether the job execution runnables have finished
      jobExecutor - the JobExecutor responsible 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, a ProcessEngineException is thrown.
      Parameters:
      condition - A Callable returning a Boolean, representing the condition to be evaluated. The method will wait until this condition evaluates to true.
      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 than maxMillisToWait, it will be adjusted to match maxMillisToWait.