In the method deleteProcessInstanceExecutionEntity() in ExecutionEntityManagerImpl.java, activiti dispatches ActivitiEventType.PROCESS_COMPLETED event as a result of process completion, reference line here -
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
2. implement an ActivitiEventListener that adds a CloseListener on CommandContext which is only executed if the Command closes successfully.