Don't fire the ActivitiEventType.PROCESS_COMPLETED event until the Command has successfully closed

Description

In the method deleteProcessInstanceExecutionEntity() in ExecutionEntityManagerImpl.java, activiti dispatches ActivitiEventType.PROCESS_COMPLETED event as a result of process completion, reference line here -
https://github.com/Activiti/Activiti/blob/29f248791495bb2e080d437b4401e26667114e42/modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntityManagerImpl.java#L400

The way it does it currently, it's possible that the current Command fails to commit while the event is still dispatched. This might lead to potential problems because this is a wrong behavior. Activiti shouldn't fire the event until the Command has successfully closed. It should either -

1. fire the event on successful closing of Command
OR
2. implement an ActivitiEventListener that adds a CloseListener on CommandContext which is only executed if the Command closes successfully.

Environment

None

Status

Assignee

Unassigned

Reporter

Ashish Joshi

Labels

None

Components

Affects versions

Priority

Medium
Configure