When will an activity instance be canceled?

Hallo,

i have a process, by which in a multiinstance block there is an intermediate cathing event, it should correlate messages sent from another application. But for some reason, by multiInstance if a message for one instance is not sent the event, the activity instance will be marked as canceled. Why? Should it not always waiting at event task?

So my general question is, When will an activity instance be canceled? I have searched in the document but found nothing.

Thanks a lot,
Best Regards

Hi,

It would be helpful if you share your process.

Best regards,
Yana

Hi Yana,

sorry, i couldn’t post it here. I would only like to know by which situations will an instance of a subprocess be canceled?

Thanks

Hi @fjiang,

It will be cancelled when it is externally terminated, when the user explicitly cancel the process or an error/escalation is thrown.

Best regards,
Yana

Hi @Yana ,

could you please tell me, where can i get which activity instance is cancelled?

In camunda Database there is a table named act_ru_execution, i could query all the activity instances belonging to the the process instance, but i couldn’t find some state like canceled.

Thanks,
Best regards

Hi @fjiang,

You can check the following rest api endpoint https://docs.camunda.org/manual/develop/reference/rest/history/activity-instance/get-activity-instance-query/
and query param canceled=true
the same can be achieved also via java api.

Best regards,
Yana

Hallo @Yana,

thanks for your help. I would like to query the unfinished activities which are older than one hour. And i use the following code:

processEngine.getHistoryService()
.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId)
.unfinished()
.startedBefore(before)
.list();

However it has missed the activities with incidents, should i add the canceled() condition?
Thanks

According to the source code it seems like that i cannot use canceled() and unfinished() at the same Time, so i must query two times, alright?

Thanks

Hi,

You are right, you need two queries, it is not possible to achieve this only with one.
When you use canceled() and unfinished() they are related with and connection (conjunctive) and not with or (disjunctive).

Best regards,
Yana