1
votes

I am a new for camunda.

I want cancel the currently running activity instance and start a new activity instance for move the token state.

But I got a hard time of how get the currently running activity instance id by the java api of camunda.

Any thougs ? Thank you all.

2

2 Answers

3
votes

Actully the question is "How get the running activity instances". And I already got the answer from somewhere.

Here is the aswer.

Just use the java api like below

ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getProcessInstanceId());
ActivityInstance[] activityInstances = activityInstance.getChildActivityInstances();

The activityInstances array is the running activity instances. you can use the ids of the activity instances to cancel running activity instance.

0
votes

Had the same trouble. This line returns a list of ids (whatever they are - user task, service task, and etc). If you don't have parallel active tasks - the list will contain a single activity id.

    processEngine.getRuntimeService().getActiveActivityIds(
        processInstance.getProcessInstanceId()
    );