Restarts process instances that were canceled or terminated asynchronously. To execute the restart synchronously,use the Restart Process Instance method.

For more information about the difference between synchronous andasynchronous execution, please refer to the relatedsection of the user guide.

Method

POST /process-definition/{id}/restart-async

Parameters

Path Parameters

Name Description
id The id of the process definition of the process instances to restart.

Request Body

A JSON object with the following properties:

Name Description
processInstanceIds A list of process instance ids to restart.
historicProcessInstanceQuery A historic process instance query like the request body described by POST /history/process-instance .
skipCustomListeners Skip execution listener invocation for activities that are started as part of this request.
skipIoMappings Skip execution of input/output variable mappings for activities that are started as part of this request.
initialVariables Set the initial set of variables during restart. By default, the last set of variables is used.
withoutBusinessKey Do not take over the business key of the historic process instance.
instructions A JSON array of instructions. The instructions are executed in the order they are in. An instruction may have the following properties:

typeMandatory. One of the following values: startBeforeActivity, startAfterActivity, startTransition. A startBeforeActivity instruction requests to enter a given activity. A startAfterActivity instruction requests to execute the single outgoing sequence flow of a given activity. A startTransition instruction requests to execute a specific sequence flow.
activityIdCan be used with instructions of types startBeforeActivity and startAfterActivity. Specifies the activity the instruction targets.
transitionIdCan be used with instructions of types startTransition. Specifies the sequence flow to start.

|type|Mandatory. One of the following values: startBeforeActivity, startAfterActivity, startTransition. A startBeforeActivity instruction requests to enter a given activity. A startAfterActivity instruction requests to execute the single outgoing sequence flow of a given activity. A startTransition instruction requests to execute a specific sequence flow.|activityId|Can be used with instructions of types startBeforeActivity and startAfterActivity. Specifies the activity the instruction targets.|transitionId|Can be used with instructions of types startTransition. Specifies the sequence flow to start.
|type|Mandatory. One of the following values: startBeforeActivity, startAfterActivity, startTransition. A startBeforeActivity instruction requests to enter a given activity. A startAfterActivity instruction requests to execute the single outgoing sequence flow of a given activity. A startTransition instruction requests to execute a specific sequence flow.
|activityId|Can be used with instructions of types startBeforeActivity and startAfterActivity. Specifies the activity the instruction targets.
|transitionId|Can be used with instructions of types startTransition. Specifies the sequence flow to start.

Result

A JSON object corresponding to the Batch interface in the engine. Itsproperties are as follows:

Name Value Description
id String The id of the created batch.
type String The type of the created batch.
totalJobs Number The total jobs of a batch is the number of batch execution jobs required to complete the batch.
batchJobsPerSeed Number The number of batch execution jobs created per seed job invocation. The batch seed job is invoked until it has created all batch execution jobs required by the batch (see totalJobs property).
invocationsPerBatchJob Number Every batch execution job invokes the command executed by the batch invocationsPerBatchJob times. E.g., for a restart of process instances in batch this specifies the number of process instances which are restarted per batch execution job.
seedJobDefinitionId String The job definition id for the seed jobs of this batch.
monitorJobDefinitionId String The job definition id for the monitor jobs of this batch.
batchJobDefinitionId String The job definition id for the batch execution jobs of this batch.
tenantId String The tenant id of the batch.

Response codes

Code Media type Description
200 application/json Request successful.
400 application/json In case following parameters are missing: instructions, activityId or transitionId, processInstanceIds or historicProcessInstanceQuery, an exception of type InvalidRequestException is returned. See the Introduction for the error response format.

Example

Restarting one or more Process Instances with known processInstanceIds:

Request

POST /process-definition/aProcessDefinitionId/restart-async

Request Body:

  1. {
  2. "instructions": [
  3. {
  4. "type": "startAfterActivity",
  5. "activityId": "aUserTask"
  6. }
  7. ],
  8. "processInstanceIds": [
  9. "aProcessInstance",
  10. "anotherProcessInstance"
  11. ],
  12. "initialVariables" : true,
  13. "skipCustomListeners" : true,
  14. "withoutBusinessKey" : true
  15. }

Response

Status 200.

  1. {
  2. "id": "aBatchId",
  3. "type": "aBatchType",
  4. "totalJobs": 10,
  5. "batchJobsPerSeed": 100,
  6. "invocationsPerBatchJob": 1,
  7. "seedJobDefinitionId": "aSeedJobDefinitionId",
  8. "monitorJobDefinitionId": "aMonitorJobDefinitionId",
  9. "batchJobDefinitionId": "aBatchJobDefinitionId",
  10. "tenantId": "aTenantId"
  11. }

Restarting one or more Process Instances using a historicProcessInstanceQuery:

Request

POST /process-definition/aProcessDefinitionId/restart-async

Request Body:

  1. {
  2. "instructions": [
  3. {
  4. "type": "startAfterActivity",
  5. "activityId": "aUserTask"
  6. }
  7. ],
  8. "initialVariables" : true,
  9. "skipCustomListeners" : true,
  10. "withoutBusinessKey" : true,
  11. "historicProcessInstanceQuery": {
  12. "processDefinitionId": "aProcessDefinitionId",
  13. "processInstanceBusinessKey" : "businessKey"
  14. }
  15. }

Response

Status 200.

  1. {
  2. "id": "aBatchId",
  3. "type": "aBatchType",
  4. "totalJobs": 10,
  5. "batchJobsPerSeed": 100,
  6. "invocationsPerBatchJob": 1,
  7. "seedJobDefinitionId": "aSeedJobDefinitionId",
  8. "monitorJobDefinitionId": "aMonitorJobDefinitionId",
  9. "batchJobDefinitionId": "aBatchJobDefinitionId",
  10. "tenantId": "aTenantId"
  11. }

原文: https://docs.camunda.org/manual/7.9/reference/rest/process-definition/post-restart-process-instance-async/