eligosource / eventsourced

A library for building reliable, scalable and distributed event-sourced applications in Scala
Apache License 2.0
828 stars 98 forks source link

How can I implement event rollback? #55

Closed Reldan closed 11 years ago

Reldan commented 11 years ago

Hello Martin. Your project is really great!

But I have a problem. I have two actors - Deposit 1 and Deposit 2. And two messages - changeDepositAmount(100) for Deposit 1 and changeDepositAmount(-100) for Deposit 2. Then Deposit 1 successfully complete operation and save message to journal. But Deposit 2 has not enough money and fail operation. For system consistency I want to rollback first message.

What is right way to do it? Could you please help me?

krasserm commented 11 years ago

Hi Reldan,

use compensation messages (defined by your application). Together with at-leat-once delivery semantics of channels you can rely on those messages being processed. Alternatively, remove logged events from the journal (available soon) but compensation messages are preferred. This doesn't ensure global concistency though. If you want to have global concistency you'll need a global/distributed transaction manager. I'm closing this ticket as it is not an issue of the library. Please use the eventsourced mailing list for asking further questions (unless you really think you found a bug).

Thanks, Martin

Reldan commented 11 years ago

Thank you!