charlessolar / Aggregates.NET

.NET event sourced domain driven design model via NServiceBus and GetEventStore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replay all events if application endpoint version upgraded

AbdoDabbas opened this issue · comments

Hi @charlessolar,
I'm facing something I don't know if it's an issue or not.
After I do some changes in the application endpoint (the models or events) and try to run the project, it asks me to upgrade the version, and after I do (Upgrade the assembly version) ALL the events in I triggered from the domain endpoint replied again.

Is that normal and should I consider it in my application handler that maybe the same event may be triggered twice so the handler needs to be idempotent ?!

If you update the whole endpoint version the app considers this a whole new endpoint which needs all the events yep.

Typically when you update the endpoint version you also stand up a new database for the endpoint to use (dont use the old one)

This is to facilitate what's known as "Red-Green" deployments where you have two versions of your app running in parallel until the update is completely tested and ready.

To prevent or manage this behavior apply the [Versioned] attribute to your events as shown in the samples

Then when you change the contents of a command or event you bump the object's version and require a new endpoint version before Agg.NET will let you continue.

If you apply versioned attribute and do not bump the version Agg.Net will NOT ask you to bump the endpoint version and replay all the events because it assumes you know what you are doing ;)

Thanks a lot @charlessolar.