The details of when is the process instance will be finished?


On the above process instance no any activity instance exists but I still can search it by runtimeService.

So someone can tell me the details of when is the process instance will be finished?

On the above process instance I cancelled all of activity instance but I still can search it by runtimeService.

Help!!

How did you perform this cancellation?

1 Like

On the above process instance has three activity instance.
The A is a userTask activity instance
The B is a IntermediateThrowEvent activity instance and that is waiting the message for continue
The C is a IntermediateThrowEvent activity instance too and that is waiting the message for continue too.
The D is a service task that will be cancel the A and B activity instance (Will not cancel itself activity instance).
Here is the java delegate of the D service task.

@Override
    public void execute(DelegateExecution execution) throws Exception {
        LOGGER.info("Cancelling all of the activity instances for the process instance -- {}", execution.getProcessInstanceId());

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

        //The sub process activity id of contain the D serviceTask activity. 
        String theActivityIdOfTheSubProcess = "SubProcess_11dge6u";

        for (ActivityInstance instance : activityInstances) {
            //Not allowed to cancel the sub process instance. Because if cancel the sub process the D activity instance will be cancelled and then cannot finished the sub process. And I want the sub process be finished normally
            if (!instance.getActivityId().equals(theActivityIdOfTheSubProcess)) {
                runtimeService.createProcessInstanceModification(execution.getProcessInstanceId()).cancelActivityInstance(instance.getId()).execute();
            }else {
                //nothing to do for now
            }
        }
    }

In my case I sended the message to trigger the C IntermediateThrowEvent activity instance for run the sub process. When the sub process finished there is no any activity instance in the process instance. But i still can search it by the runtimeService.

When I check the table ACT_RU_EXECUTION find the column ACT_ID_ value is SubProcess_11dge6u
The SubProcess_11dge6u is the sub process activity id of contain the D serviceTask activity.

Thank for your help.