API behaving wrongly, process instances and definition

Hi Team,
Let me first describe my use-case;

Use-case

  1. We have multiple definitions deployed in camunda which could have multiple process-instances.
    Now, we need to disable/enable these definitions as need bases.
  2. We may also need to find, how many active process-instances are there for a given definition (by id).

Our-Findings

Use-case 1: We found that camunda provide use below API which can be utilized to disable/enable definition.
Our understanding is “suspended” is as equivalent to disabling/enabling definition.
API: Activate/Suspend Process Definition By Id | docs.camunda.org

As described, suspended=true means its disabled. As well we can use “includeProcessInstances” to disable all the process-instances as well.

Use-case 2: For this, we found below API;

GET /process-instance/count
we are utilizing following query param: processDefinitionId, suspended

Now as per our use-case, we should invoke the api as below;
/process-instance/count?suspended=false&processDefinitionId=defId

Which will give use count of active process instances within a definition.

Now the api; /process-instance/count is misbehaving.
Here is what and how we tested;

  1. Disable a definition by definition id
    /process-definition/defId/suspended
    {
    “suspended” : true,
    “includeProcessInstances” : true
    }
    Which will disable definition and process-instances as well, which we verfiy by below api;
    /process-instance?processDefinitionId=defId
    [
    {
    “links”: [],
    “id”: “00539350-b74e-11e9-b754-366d22453910”,
    “definitionId”: “defId”,
    “businessKey”: null,
    “caseInstanceId”: null,
    “ended”: false,
    “suspended”: true,
    “tenantId”: null
    },

    ]

Now, as we invoke /process-instance/count api; it won’t behave correctly;
with both suspended = true or false gives back same count;

https://workflowenginecore-qal.api.intuit.com/rest/engine/default/process-instance/count?suspended=false&processDefinitionId=defId
{
“count”: 25
}

https://workflowenginecore-qal.api.intuit.com/rest/engine/default/process-instance/count?suspended=true&processDefinitionId=defId
{
“count”: 25
}

Whereas it should return 0 in the first call, and 25 in the second call.

EDIT: Same is happening for query param “active”

Hi @Nitin_Gupta

To get count of active instances, only active parameter should be passed with true value instead of suspended with false value.

See in below URL the descriptions of both query parameters: suspended and active

https://docs.camunda.org/manual/latest/reference/rest/process-instance/get-query-count/#parameters

Even “active” parameter mis-behaving as per above trace.
Even processInstance are suspended, but still counted as active.

Hi @Nitin_Gupta,

Could you please post the payload you are trying…

It is there in question.

Hi @Nitin_Gupta
In the question, only suspended is passed

Hi,
I mention in the edit.

Here it is
https://workflowenginecore-qal.api.intuit.com/rest/engine/default/process-instance/count?active=false&processDefinitionId=defId
{
“count”: 25
}

https://workflowenginecore-qal.api.intuit.com/rest/engine/default/process-instance/count?active=true&processDefinitionId=defId
{
“count”: 25
}