camunda / camunda-bpm-platform

Flexible framework for workflow and decision automation with BPMN and DMN. Integration with Quarkus, Spring, Spring Boot, CDI.
https://camunda.com/
Apache License 2.0
4.11k stars 1.55k forks source link

Builtin task listeners are not executed in correct order #4042

Closed mboskamp closed 9 months ago

mboskamp commented 9 months ago

Environment (Required on creation)

Any Camunda version

Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket)

When registering multiple builtin task listeners with BPMN parse listeners using customPreBPMNParseListeners and customPostBPMNParseListeners, the order of the task listener is not always consistent.

During normal BPMN execution via the process engine, the order is reversed (first post, then pre). After process instance modification, the listener order is not reversed (first pre, then post).

Steps to reproduce (Required on creation)

  1. register two BPMN parse listener for user tasks, one as customPreBPMNParseListeners and one as customPostBPMNParseListeners
  2. both parse listener register a task listener on task 'create'
  3. Execute the process
  4. Execute a process instance modification starting before the user task

Observed Behavior (Required on creation)

During normal execution of the process, the task listener registered through the customPostBPMNParseListeners fires first, the other task listener second. After process instance modification, the task listener registered through the customPreBPMNParseListeners fires first, the other task listener second.

Expected behavior (Required on creation)

The task listener registered through the customPreBPMNParseListeners always fires before the task listener registered through customPostBPMNParseListeners.

Root Cause (Required on prioritization)

Solution Ideas

Hints

Links

Breakdown

### Pull Requests
- [ ] https://github.com/camunda/camunda-bpm-platform/pull/4045
- [ ] https://github.com/camunda/camunda-bpm-platform-maintenance/pull/1159
- [ ] https://github.com/camunda/camunda-docs-manual/pull/1582
- [ ] https://github.com/camunda/camunda-docs-manual/pull/1583
- [ ] https://github.com/camunda/camunda-bpm-platform/pull/4057
- [ ] https://github.com/camunda/camunda-bpm-platform-maintenance/pull/1161
- [ ] https://github.com/camunda/camunda-docs-manual/pull/1587
- [ ] https://github.com/camunda/camunda-docs-manual/pull/1588

Dev2QA handover

mboskamp commented 9 months ago

The 7.20 backport is missing and will happen after the master PR is merged.

mboskamp commented 9 months ago

Reopened to move the logic that creates a joined map (of builtinTaskListener and regular taskListener) into another method that is not as frequently called as the TaskDefinition#getTask method and improve the docs.