We’re looking for some advise ensuring atomic operation on more than one actor.
We’ve considered two-phase-commit and saga pattern.
However, both seem bad because persisting to DB could fail.
(we want that all or no journals will be persisted by a command)
We thought that transaction coordinator actor MUST append all journals at once to ensure strong consistency.
So, we are considering transformed two-phase-commit.
For example, let’s consider an account as an actor.
If we want to transfer 100$ from account A to account B,
the coordinator actor tells account A to decrease 100$.
the coordinator actor tells account B to increase 100$.
If both responded, the coordinator actor persists journals
PersistentRepr(payload: Decreased(100$), persistenceId: "A"),
PersistentRepr(payload: Increased(100$), persistenceId: "B") then send
COMMITED and which events are applied to A and B.
It’s similar to two-phase-commit except that coordinator performs persisting events.
Is this design reasonable?