Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-7434

@StartActivity CDI listener is invoked twice via CDI event bridge for BPMN start events

    Details

    • Type: Bug Report
    • Status: Open
    • Priority: L3 - Default
    • Resolution: Unresolved
    • Affects Version/s: 7.5.0, 7.6.0, 7.4.8, 7.7.0
    • Fix Version/s: 7.4.x, 7.5.x, 7.6.x, 7.7.x
    • Component/s: engine
    • Labels:

      Description

      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.

        Activity

        thorben.lindhauer Thorben Lindhauer created issue -
        thorben.lindhauer Thorben Lindhauer made changes -
        Field Original Value New Value
        Link This issue is depended on by SUPPORT-3049 [ SUPPORT-3049 ]
        thorben.lindhauer Thorben Lindhauer made changes -
        Summary Activity start event is dispatched twice via CDI event bridge for start events @StartActivity CDI listener is invoked twice via CDI event bridge for start events
        thorben.lindhauer Thorben Lindhauer made changes -
        Summary @StartActivity CDI listener is invoked twice via CDI event bridge for start events @StartActivity CDI listener is invoked twice via CDI event bridge for BPMN start events
        thorben.lindhauer Thorben Lindhauer made changes -
        Affects Version/s 7.4.8 [ 14601 ]
        Affects Version/s 7.6.0 [ 14490 ]
        Affects Version/s 7.5.0 [ 14091 ]
        Affects Version/s 7.7.0 [ 14607 ]
        thorben.lindhauer Thorben Lindhauer made changes -
        Description 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.:

        {code}
        @Named
        @Singleton
        public class ListenerBean {

          public void logStart(@Observes @StartActivity("StartEvent_1") BusinessProcessEvent aBusinessProcessEvent) {
            // do something useful
          }
        }
        {code}

        {{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.
        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.:

        {code}
        @Named
        @Singleton
        public class ListenerBean {

          public void logStart(@Observes @StartActivity("StartEvent_1") BusinessProcessEvent aBusinessProcessEvent) {
            // do something useful
          }
        }
        {code}

        {{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.
        matthijs.burke Matthijs Burke made changes -
        Fix Version/s 7.4.x [ 14196 ]
        Fix Version/s 7.5.x [ 14200 ]
        Fix Version/s 7.6.x [ 14597 ]
        Fix Version/s 7.7.x [ 14699 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            thorben.lindhauer Thorben Lindhauer
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:

              Development