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

I do not get reliable the id of the activity inside the listener for which the execution listener has been notified

    Details

    • Type: Bug Report
    • Status: Open
    • Priority: L3 - Default
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 7.2.x
    • Component/s: engine
    • Labels:

      Description

      Given:

      <process id="executionListener">
        <extensionElements>
          <camunda:executionListener class="MyExecutionListener" event="end" />
        </extensionElements>
        
        <startEvent id="theStart" />
        <sequenceFlow sourceRef="theStart" targetRef="scriptTask" />
      
        <scriptTask id="scriptTask" scriptFormat="groovy">
          <extensionElements>
            <camunda:executionListener class="MyExecutionListener" event="end" />
          </extensionElements>
          <script><![CDATA[throw new org.camunda.bpm.engine.delegate.BpmnError("123");]]></script>
        </scriptTask>
      
        <sequenceFlow sourceRef="scriptTask" targetRef="theEnd" />
        <endEvent id="theEnd" />
      
      </process>
      
      public MyExecutionListener implements ExecutionListener {
        public void notify(DelegateExecution execution) throws Exception {
          System.out.println("event type: " + execution.getEventName());
          System.out.println("current activity: " + execution.getCurrentActivityId());
        }
      }
      

      When:
      start an instance of the process

      Then:
      The provided execution listener MyExecutionListener is invoked twice:
      1) the script task is ended, the following is logged out:

      • event type: end
      • event type: scriptTask
        2) the process is ended, the following is logged out:
      • event type: end
      • event type: scriptTask

      Problem:
      In both cases the DelegateExecution#getCurrrentActivityId() returns scriptTask, so that it is not possible to determine whether the 'end' is for the overall process instance/execution or for the individual activity which was cancelled/ended.

      Possible Solutions:

      • We expose the CoreExecution#getEventSource() which sets always the correct activity for which the execution listener is invoked (and in case of the process it returns the process definition). But be aware, that instead exposing simple the method we can only expose the id of the event source. As a consequence, inside the listener the method Delegate#getEventSourceId() must be used.
      • We fix that DelegateExecution#getCurrentActivityId() returns not scriptTask in case it is notified for the 'end' for the overall process instance/execution

      Hint:
      This is especially a problem, if you provide an execution listener via a process application (ie. ProcessApplicationInterface#getExecutionListener().

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              roman.smirnov Smirnov Roman
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Development