Event Dispatcher propagates events before the db session is flushed

Description

Event Dispatcher propagates events before the db session is flushed. Thus if a database error occurs (like a OptimisticLock), the events are inconsistent.

Consider the scenario in a clustered environment:
Event #1 - Create Activity A - ACTIVITY_CREATED
Event #2 - Claim Activity A for user "x" - TASK_ASSIGNED
Event #3 (a) - Complete Activity A - ACTIVITY_COMPLETED
Event #3 (b) - Unclaim Activity A - TASK_ASSIGNED

Event #3 (a) and Event #3 (b) ocurr in parallel and both events are dispatched.
However Event #3 (b) is not persisted because a OptimisticLockException was thrown. Therefore "Event #3 (b)" is inconsistent.

Environment

None

Status

Assignee

Joram Barrez

Reporter

Erich Silvestre

Labels

None

Components

Affects versions

Priority

Lowest
Configure