- asynchronous (non-blocking) execution
- execution can utilize multiple threads and job executors
- decoupling of execution, i.e., every batch execution job uses its own transaction
- manual polling for completion of the batch
- contention with other jobs executed by the process engine
- a batch can fail partially while a subset was already executed, e.g., some process instances were migrated where others failed
- Seed job: creates all batch execution jobs required to complete the batch
- Execution jobs: the actual execution of the batch command, e.g., the process instance migration
- Monitor job: after the seed job finished, it monitors the progress of the batch execution and completion
API
The following gives an overview of the Java API for batches.Creating a Batch
A batch is created by executing a process engine command asynchronously. You can find a list of currently supported batch types in the Batch operations. The Java API can be used to create Batch command. Refer to specific commands for exact usage examples.Query a Batch
You can query a running batch by the id and the type, for example to query for all running process instance migration batches.Batch Statistics
You can query for statistics of batches by using the management service. The batch statistics will contain information about the remaining, completed and failed batch execution jobs.History of a Batch
For the history levelFULL a historic batch entry is created. You
can query it using the history service.
Suspend a Batch
To pause the execution of a batch and all corresponding jobs, a batch can be suspended using the management service.Delete a Batch
A running batch can be deleted using the management service.For a running batch which still executes jobs it is recommended
to suspend the batch before deleting it.
See the Suspend a Batch section for details.
Priority of a Batch
As all batch jobs are executed using the job executor, it is possible to use the job prioritization feature to adjust the priority of batch jobs. The default batch job priority is set by the process engine configurationbatchJobPriority.
It is possible to adjust the priority of a specific batch job
definition or even a single batch job
using the management service.
Operation log
Please note that a user operation log is written for Batch creation itself only, execution of the seed job as well as individual jobs that perform operations are performed by Job Executor and therefore are not considered to be user operations.Job Definitions
Seed Job
A batch initially creates a seed job. This seed will be repeatedly executed to create all batch execution jobs. For example if a user starts a process instance migration batch for 1000 process instances. With the default process engine configuration the seed job will create 10 batch execution jobs on every invocation. Every execution job will migrate 1 process instance. In sum the seed job will be invoked 100 times, until it has created the 1000 execution jobs required to complete the batch. The Java API can be used to get the job definition for the seed job of a batch:Execution Jobs
The execution of a batch is split into several execution jobs. The specific number of jobs depends on the total jobs of the batch and the process engine configuration (see seed job). Every execution job executes the actual batch command for a given number of invocations, e.g., migrate a number of process instances. The execution jobs will be executed by the job executor. They behave like other jobs which means they can fail and the job executor will retry failed batch execution jobs. Also, there will be incidents for failed batch execution jobs with no retries left. The Java API can be used to get the job definition for the execution jobs of a batch, e.g., for a process instance migration batch:Monitor Job
After all batch execution jobs were created by the seed job a monitor job is created for the batch. This job regularly polls if the batch has been completed, i.e., all batch execution jobs were completed. The polling interval can be configured by thebatchPollTime (default: 30 seconds) property of the process engine configuration.
The Java API can be used to get the job definition for the monitor job of a
batch:
Configuration
You can configure the number of jobs created by every seed job invocationbatchJobsPerSeed (default: 100) and the number of invocations per batch
execution job invocationsPerBatchJob (default: 1) in the
process engine configuration.
The number of invocations per batch execution job can be changed for each batch
operation type individually with the help of the process engine configuration property
invocationsPerBatchJobByBatchType. In case you haven’t
specified the invocations per batch job by type, the configuration falls back to the global
configuration specified via invocationsPerBatchJob.
You can configure the property in three ways:
- Programmatically with the help of a Process Engine Plugin
- In Spring-based environments via Spring XML Configuration
- In Spring Boot environment via the
application.yamlfile