event-sourcing-kafka-streams
event-sourcing-kafka-streams copied to clipboard
Question: why we need to validate version in command handler?
Thanks for sharing your code! Very interesting!
Just one question: I see that you do an "optimistic lock" by checking the expected version in the command with the version of the snapshot. Why you need this?
I mean using Kafka "exactly once" does not guarantee that there is only one "thread" that apply commands on a single aggregate, so why checking the version. I would expect that it always match.
I have tried to write a similar POC but without the "optimistic lock" and with some changes: https://github.com/davideicardi/books-catalog-es
I appreciate any feedback.
The most important part is the event sourcing topology described here:
)
Code is here: https://github.com/davideicardi/books-catalog-es/blob/master/sample/src/main/scala/catalog/authors/streaming/AuthorsTopology.scala