Skip to content

Commit

Permalink
effects.md improve description of synchronous command and non-atomic …
Browse files Browse the repository at this point in the history
…transaction (cloudstateio#214)
  • Loading branch information
tringuyen-yw authored Mar 24, 2020
1 parent 4b190a7 commit c994cb0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/src/main/paradox/user/features/effects.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ The command won't be forwarded until any state actions request by the command ha

An entity may also emit one or more effects. An effect is something whose result has no impact on the result of the current command - if it fails, the current command still succeeds. The result of the effect is therefore ignored. Effects are only performed after the successful completion of any state actions requested by the command handler.

Effects may be declared as synchronous or asynchronous. Asynchronous commands are fired and forgotten - command processing continues while the command is being asynchronously processed. Meanwhile, synchronous commands are processed synchronously, one at a time, and the final result of the command handler, either a reply or a forward, is not sent until all synchronous commands are completed.
Effects may be declared as synchronous or asynchronous. Asynchronous commands are fired and forgotten - command processing continues while the command is being asynchronously processed. Meanwhile, synchronous commands are processed in order, one at a time, and the final result of the command handler, either a reply or a forward, is not sent until all synchronous commands are completed.

## Transactional concerns

It's important to note that forwarded commands, and commands emitted as side effects, are not transactionally completed. If the user function or store fails while a forwarded command is executing, the original command that triggered it will not be rolled back. Hence, forwarding and effects should not be used to update multiple entities at once if partial updates is a problem. In such cases, it's best to initiate commands from an event log consumer (future Cloudstate functionality), which can guarantee that a sequence of operations will run through to completion.
It's important to note that forwarded commands, and commands emitted as side effects, are non-atomic (atomic means either all transactions succeeded or none). If the user function or store fails while a forwarded command is executing, the original command that triggered it will not be rolled back. Hence, forwarding and effects should not be used to update multiple entities at once if partial updates is a problem. In such cases, it's best to initiate commands from an event log consumer (future Cloudstate functionality), which can guarantee that a sequence of operations will run through to completion.

0 comments on commit c994cb0

Please sign in to comment.