Detect cancelled process instance

We have a process that can end up in a user task. If the user goes into the cockpit and decides to just cancel the instance, we need to be able to catch this and clean up. This used to work but no longer seems to - we are using v7.15.3-ee.

What we have implemented looks like this in the BPMN:
<bpmn:process id=“ProcessID” name=“ProcessName” isExecutable=“true” camunda:versionTag=“1.7.0” camunda:historyTimeToLive=“6” camunda:isStartableInTasklist=“false”>
bpmn:extensionElements
<camunda:executionListener delegateExpression=“${processLifecycleListener}” event=“end” />
</bpmn:extensionElements>

and then there is some Java code that looks like:
public class ProcessLifecycleListener implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
final ExecutionEntity executionEntity = (ExecutionEntity) execution;
if (executionEntity.isCanceled()) {
LOGGER.debug(“Process instance {} was cancelled”, executionEntity.getProcessBusinessKey());

As I have already said, this used to work but now the listener only gets called when the process completes normally and not when it is cancelled. After cancelling the instance says ‘Cancelled externally’ in the cockpit.

Any ideas on how I get this to work?

Thanks
Mike

Just checked using Chrome Developer and found that clicking on the ‘Delete running process instances’ button causes the delete to happen with skipCustomListeners=true.

I assume that this is my issue. Is there a way to change this behaviour so that custom listeners are invoked?

This is optional parameters to decide whether to skip custom listeners are not while deleting. If required you can deselect the skipCustomListeners

How do I deselect it when ist is the action taken when I click on the ‘x’ in the cockpit?

@mike_g refer this:

Kapture 2021-08-01 at 15.31.24 (2)

Thanks so much for your help. In all the years I have been using and supporting Camunda I have never noticed that check box.

Much appreciated,
Mike

1 Like