On Camunda 7.5, REST API queries for process instance and task history return no results when querying by Process Definition Key, when the associated deployment has been deleted (even though the Cascade parameter has not been set to TRUE.) However, when querying for the same records based on process instance ID, the records are returned.
These steps demonstrate the problem.
- Create a deployment:
POST engine-rest/deployment/create
The returned data is:
{
"links": [
{
"method": "GET",
"href": "http://dev-solutions.accusoft.com:8080/engine-rest/deployment/a37ccda8-d6a2-11e6-ac5c-0242ac120003",
"rel": "self"
}
],
"id": "a37ccda8-d6a2-11e6-ac5c-0242ac120003",
"name": "TestParallelEnds",
"source": null,
"deploymentTime": "2017-01-09T19:34:29",
"tenantId": "sbb"
}
- Get the Process Definition:
GET engine-rest/process-definition?deploymentId=a37ccda8-d6a2-11e6-ac5c-0242ac120003
The returned data is:
[
{
"id": "ID_Process_ParallelEnds:1:a383364a-d6a2-11e6-ac5c-0242ac120003",
"key": "ID_Process_ParallelEnds",
"category": "http://bpmn.io/schema/bpmn",
"description": "This workflow has parallel paths that end in two different end events. It is intended to be used for testing.",
"name": "Parallel Ends",
"version": 1,
"resource": "parallel-ends.bpmn",
"deploymentId": "a37ccda8-d6a2-11e6-ac5c-0242ac120003",
"diagram": null,
"suspended": false,
"tenantId": "sbb",
"versionTag": null
}
]
-
Start an instance of this deployment and run it to conclusion.
-
Get the Instance History (query with processDefinitionKey):
GET engine-rest/history/process-instance?processDefinitionKey=ID_Process_ParallelEnds
The returned data is:
[
{
"id": "eff7d046-d6a2-11e6-ac5c-0242ac120003",
"businessKey": null,
"processDefinitionId": "ID_Process_ParallelEnds:1:a383364a-d6a2-11e6-ac5c-0242ac120003",
"processDefinitionKey": "ID_Process_ParallelEnds",
"startTime": "2017-01-09T19:36:38",
"endTime": "2017-01-09T19:37:40",
"durationInMillis": 62626,
"startUserId": "accusoft",
"startActivityId": "StartEvent_1",
"deleteReason": null,
"superProcessInstanceId": null,
"superCaseInstanceId": null,
"caseInstanceId": null,
"tenantId": "sbb"
}
]
- Get History User Tasks (query with processDefinitionKey): ``GET `engine-rest/history/task?processDefinitionKey=ID_Process_ParallelEnds```
The returned data is:
[
{
"id": "effc8b42-d6a2-11e6-ac5c-0242ac120003",
"processDefinitionKey": "ID_Process_ParallelEnds",
"processDefinitionId": "ID_Process_ParallelEnds:1:a383364a-d6a2-11e6-ac5c-0242ac120003",
"processInstanceId": "eff7d046-d6a2-11e6-ac5c-0242ac120003",
"executionId": "eff7f75e-d6a2-11e6-ac5c-0242ac120003",
"caseDefinitionKey": null,
"caseDefinitionId": null,
"caseInstanceId": null,
"caseExecutionId": null,
"activityInstanceId": "UserTask_0sgpakl:eff7f75f-d6a2-11e6-ac5c-0242ac120003",
"name": "Task A",
"description": null,
"deleteReason": "completed",
"owner": null,
"assignee": "accusoft",
"startTime": "2017-01-09T19:36:38",
"endTime": "2017-01-09T19:37:13",
"duration": 35647,
"taskDefinitionKey": "UserTask_0sgpakl",
"priority": 50,
"due": null,
"parentTaskId": null,
"followUp": null,
"tenantId": "sbb"
}, ...
-
Delete the deployment:
DEL engine-rest/deployment/a37ccda8-d6a2-11e6-ac5c-0242ac120003
-
Get the Instance History (query with processDefinitionKey):
GET engine-rest/history/process-instance?processDefinitionKey=ID_Process_ParallelEnds
The returned data is an empty array. -
Get History User Tasks (query with processDefinitionKey):
GET engine-rest/history/task?processDefinitionKey=ID_Process_ParallelEnds
The returned data is an empty array. -
Get the Instance History (query for the specific instance):
GET engine-rest/history/process-instance/eff7d046-d6a2-11e6-ac5c-0242ac120003
The returned data is:
{
"id": "eff7d046-d6a2-11e6-ac5c-0242ac120003",
"businessKey": null,
"processDefinitionId": "ID_Process_ParallelEnds:1:a383364a-d6a2-11e6-ac5c-0242ac120003",
"processDefinitionKey": "ID_Process_ParallelEnds",
"startTime": "2017-01-09T19:36:38",
"endTime": "2017-01-09T19:37:40",
"durationInMillis": 62626,
"startUserId": "accusoft",
"startActivityId": "StartEvent_1",
"deleteReason": null,
"superProcessInstanceId": null,
"superCaseInstanceId": null,
"caseInstanceId": null,
"tenantId": "sbb"
}
- Get the Task History(query for the specific process instance):
GET engine-rest/history/task?processInstanceId=eff7d046-d6a2-11e6-ac5c-0242ac120003
The returned data is:
[
{
"id": "effc8b42-d6a2-11e6-ac5c-0242ac120003",
"processDefinitionKey": "ID_Process_ParallelEnds",
"processDefinitionId": "ID_Process_ParallelEnds:1:a383364a-d6a2-11e6-ac5c-0242ac120003",
"processInstanceId": "eff7d046-d6a2-11e6-ac5c-0242ac120003",
"executionId": "eff7f75e-d6a2-11e6-ac5c-0242ac120003",
"caseDefinitionKey": null,
"caseDefinitionId": null,
"caseInstanceId": null,
"caseExecutionId": null,
"activityInstanceId": "UserTask_0sgpakl:eff7f75f-d6a2-11e6-ac5c-0242ac120003",
"name": "Task A",
"description": null,
"deleteReason": "completed",
"owner": null,
"assignee": "accusoft",
"startTime": "2017-01-09T19:36:38",
"endTime": "2017-01-09T19:37:13",
"duration": 35647,
"taskDefinitionKey": "UserTask_0sgpakl",
"priority": 50,
"due": null,
"parentTaskId": null,
"followUp": null,
"tenantId": "sbb"
}, ...
So we see that the history data is still present. As expected, it was not deleted when the deployment was deleted. However, we can not retrieve this data by querying based on the Process Definition ID. This makes it inconvenient to retrieve the history data.
Is this lack of functionality by design or is it a defect? It seems to me that since the processDefinitionKey fields of the historic data are populated, we should be able to query based on the processDefinitionKey, even if the associated deployment has been deleted.