Skip to content

Add events to the list of uncommitted in Aggregate only if they are successfully applied to the entity #1313

@dmitrykuzmin

Description

@dmitrykuzmin

Currently, the method Aggregate.apply(List<Event> events) always adds all events to the in-memory list of aggregate's uncommittedEvents, ignoring the actual result of applying them to the entity.

When multiple messages are dispatched in a batch, the entities may be cached. In this situation, if the earlier dispatch produces events which render aggregate state invalid, but the following one is successful, all of the events will be actually saved to the storage, forever corrupting the aggregate history.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions