Skip to content

Instantly share code, notes, and snippets.

@vertexvaar
Last active January 7, 2019 14:39
Show Gist options
  • Select an option

  • Save vertexvaar/383fef353c80221add49bcf9f756d543 to your computer and use it in GitHub Desktop.

Select an option

Save vertexvaar/383fef353c80221add49bcf9f756d543 to your computer and use it in GitHub Desktop.
Event Sourcing / CQRS Obstacle Dodging

YAGNI! (Think twice before choosing ES and at least 10 times before choosing CQRS - Anyone with experience ever)

Uniqueness:

  • Single value table on command side with index
  • Implementable as service or sth. like that

Crossing ES borders:

  • Use ProcessManager for creating ES-external entities

Referencing Projections in ORM

  • Will not be able to replay because of constraints -> Only save identifiers, no FK constraints!

Domain logic implementatin

  • e.g. Calculation of prices (-> Use shared logic container/model ?)

Implementation order

  • What's needed first? If you need more output you need more vent details. You can't think of any required event detail beforehand. -> 1. Output, 2. Event, 3. Command, 4. Aggregate Root & Handler, 5. Projection. Hint: The more event details you have the easier your projections will be.

Event versioning

  • Events may get more properties over time -> old events miss arguments but are still historically valid
  • Solution 1 (works probably always): New events for new properties. Create a new Event class that holds all new properties. -> Clear version border
  • Solution 2 (only specific use cases): Provide defaults in the database (attention if properties are serialized!) and add the new property to the event.
  • Solution 3 (only specifc cases): Make the constructor argument optional with a default value that makes sense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment