Batch operations

The following operations can be executed asynchronously

All batch operations rely on corresponding methods that provide the possibility to operate on a list of entities synchronously. Please refer to the general Batch documentation to understand the creation process better.

Asynchronous operations can be performed based on a list of specific instances as well as on the result of a query providing a resulting list of instances. If both a list of instances and a query are provided, the resulting set of affected instances will consist of the union of those two subsets.

Cancellation Of Running Process Instances

Cancellation of running process instances can be performed asynchronously using the following Java API method invocation:

List<String> processInstanceIds = ...;
runtimeService.deleteProcessInstancesAsync(
        processInstanceIds, null, REASON);

Deletion Of Historic Process Instances

Deletion of historic process instances can be performed asynchronously using the following Java API method invocation:

List<String> historicProcessInstanceIds = ...;
historyService.deleteHistoricProcessInstancesAsync(
        historicProcessInstanceIds, TEST_REASON);

Update Suspend State Of Process Instances

Update the suspension state of multiple process instances asynchronously using the following Java API method invocation:

List<String> processInstanceIds = ...;
runtimeService.updateProcessInstanceSuspensionState().byProcessInstanceIds(
  processInstanceIds).suspendAsync();

Setting Retries Of Jobs Associated With Process Instances

Setting retries of jobs associated with process instances can be performed asynchronously using the following Java API method invocation:

List<String> processInstanceIds = ...;
int retries = ...;
managementService.setJobRetriesAsync(
        processInstanceIds, null, retries);

Setting Retries Of External Tasks

Setting retries of external tasks can be performed asynchronously using the following Java API method invocation:

List<String> externalTaskIds = ...;
externalTaskService.setRetriesAsync(
        externalTaskIds, TEST_REASON);

Set a Removal Time

Sometimes it is necessary to postpone or even prevent the deletion of certain historic instances. A removal time can be set asynchronously to historic processes, decisions and batches.

The following modes can be chosen:

  • Absolute: Sets the removal time to an arbitrary date
    • .absoluteRemovalTime(Date removalTime)
  • Cleared: Resets the removal time (represented as null-value); Instances without a removal time are not cleaned-up
    • .clearedRemovalTime()
  • Calculated: Recalculates the removal time based on the Workflow Engine’s settings (base time + TTL)
    • .calculatedRemovalTime()

Historic process and decision instances can be part of a hierarchy. To set the same removal time for all instances within a hierarchy, the method .hierarchical() needs to be called.

Historic Process Instances

HistoricProcessInstanceQuery query = 
  historyService.createHistoricProcessInstanceQuery();

Batch batch = historyService.setRemovalTimeToHistoricProcessInstances()
  .absoluteRemovalTime(new Date()) // sets an absolute removal time
   // .clearedRemovalTime()        // resets the removal time to null
   // .calculatedRemovalTime()     // calculation based on the engine's configuration
  .byQuery(query)
  .byIds("693206dd-11e9-b7cb-be5e0f7575b7", "...")
   // .hierarchical()              // sets a removal time across the hierarchy
  .executeAsync();

Historic Decision Instances

HistoricDecisionInstanceQuery query = 
  historyService.createHistoricDecisionInstanceQuery();

Batch batch = historyService.setRemovalTimeToHistoricDecisionInstances()
  .absoluteRemovalTime(new Date()) // sets an absolute removal time
   // .clearedRemovalTime()        // resets the removal time to null
   // .calculatedRemovalTime()     // calculation based on the engine's configuration 
  .byQuery(query)
  .byIds("693206dd-11e9-b7cb-be5e0f7575b7", "...")
   // .hierarchical()              // sets a removal time across the hierarchy
  .executeAsync();

Known limitation

The .hierarchical() flag for the decision instances batch operation only sets the removal time within the decision hierarchy. If a decision was called by a Business Rule Task, the calling process instances (including other process instances that are present in the hierarchy) are not updated.

To update all child instances along the hierarchy of a root process instance (all process as well as decision instances), please use the batch operation for process instances with the .hierarchical() flag enabled.

Historic Batches

HistoricBatchQuery query = historyService.createHistoricBatchQuery();

Batch batch = historyService.setRemovalTimeToHistoricBatches()
  .absoluteRemovalTime(new Date()) // sets an absolute removal time
   // .clearedRemovalTime()        // resets the removal time to null
   // .calculatedRemovalTime()     // calculation based on the engine's configuration
  .byQuery(query)
  .byIds("693206dd-11e9-b7cb-be5e0f7575b7", "...")
  .executeAsync();

On this Page: