Scenario: Shared Engine, any application server, process application using the CDI event bridge (https://docs.camunda.org/manual/7.6/user-guide/cdi-java-ee-integration/the-cdi-event-bridge/)
Process application has a CDI bean that listens for the start execution event of the BPMN start event, e.g.:
@Named @Singleton public class ListenerBean { public void logStart(@Observes @StartActivity("StartEvent_1") BusinessProcessEvent aBusinessProcessEvent) { // do something useful } }
StartEvent_1 is the start event of the process.
Observed behavior: Whenever a process instance is started, the listener is invoked twice.
Expected behavior: Listener is invoked once
Reason for observed behavior: The CdiEventListener that is provided by the process application is invoked once for process start and once for activity start. This is good. However, both invocations produce the same CDI event, because the context execution has already activity id = <start event id> when the process start listener is invoked. That means, the core problem is in org.camunda.bpm.engine.cdi.impl.event.CdiEventListener.createEvent(DelegateExecution) that should create distinguishable events for the two invocations.
Side note: This cannot be reproduced with a unit test that uses CdiEventSupportBpmnParseListener to register the CdiEventListener, because the former does not register the listener for process start.
Similar issues might exist with end events.