Skip to content

Spliting events to more than one event #917

Closed

Description

@ZagreusHere

Hello,
Is it possible to upgrade/split an Event to more than one event.

Be careful when working with event upgraders that return zero or more than one event, as this has an influence on the aggregate version and you need to make sure that the aggregate sequence number on upgraded events are valid in regard to the aggregate history.

for example:

  • emit event 1 → aggregate version 1
  • emit event 2 → aggregate version 2
  • emit event 3 → aggregate version 3
  • here comes the upgrader which upgrades/splits the event 2 into two events. Now the event 3 has an invalid sequence number.

is there a recommended way to split an old event to new events or update the sequence number with a upgrader?

Activity

  1. rasmus commented on Nov 17, 2021

    @rasmus
    Member

    Hi @ZagreusHere

    Since event upgraders are created for each load, you know that all events that pass through the event upgrader originates from the same event stream. Use can use the IDomainEventFactory to create new IDomainEvent from existing events and update all the sequence numbers as you read through the events.

    https://github.com/eventflow/EventFlow/blob/develop-v1/Source/EventFlow/EventStores/IDomainEventFactory.cs

  2. ZagreusHere commented on Nov 19, 2021

    @ZagreusHere
    Author

    Hello @rasmus,

    Thank you for the Response. It helped a lot in fixing my problem.

  3. locked and limited conversation to collaborators on Feb 25, 2022
  4. converted this issue into a discussion #930 on Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions