Exception is thrown while suspending the workflow

The following exception is thrown while suspending a workflow if there is already a workflow running with the same business key.

[jobexecutor]-[146 ]-ENGINE-14006 Exception while executing job f6252c2b-b0e2-11ea-33c1-acde42531179: org.camunda.bpm.engine.SuspendedEntityInteractionException: ENGINE-03043 Execution with id ‘7a780bc3-b0f2-11ea-33c1-acde42531179’ is suspended.

Our service is listening to workflow process start event

@EventListener(condition = "#delegateExecution.eventName=='start' && #delegateExecution.getBpmnModelElementInstance() instanceof  T(org.camunda.bpm.model.bpmn.instance.StartEvent) && #delegateExecution.getParentId() == null")
    public void onWorkflowStart(DelegateExecution delegateExecution) throws Exception {
        if (isProcessStartEvent(delegateExecution)) {
            startSynchronization(delegateExecution);
        }
    }

private boolean isProcessStartEvent(DelegateExecution delegateExecution) {
        return ((StartEvent) delegateExecution.getBpmnModelElementInstance()).getIncoming().isEmpty() && delegateExecution.getActivityInstanceId() == null;
    }

If there is a workflow already running for a given business key, the next workflow is suspended in the beginning

//org.camunda.bpm.engine.ManagementService
//org.camunda.bpm.engine.RuntimeService
runtimeService.suspendProcessInstanceById(processInstanceId);
managementService.suspendJobByProcessInstanceId(processInstanceId);

Camunda is throwing the following exception org.camunda.bpm.engine.SuspendedEntityInteractionException. Wrapping the above two lines with try/catch block didn’t work as well, it looks like it’s caught inside Camunda Engine code.

Second workflow is suspended as expected, but exception is printed on the console.

I was able to fix the above issue by using Non-Exclusive jobs. Unchecking “Exclusive” option fixed the issue.

Exclusive jobs are most likely executed by the same thread, which means they are executed synchronously to avoid the optimistic locking exception. The Job Executor | docs.camunda.org

Unchecking Exclusive made sure the jobs are are executed in parallel