core-java icon indicating copy to clipboard operation
core-java copied to clipboard

Handle failed aggregate loading during message delivery

Open dmytro-kashcheiev opened this issue 2 years ago • 0 comments

Delivery behavior, when it's impossible to load Aggregate for some reason (a coding mistake, storage issues, etc.), is unclear. It looks like all commands and events that point to corrupted Aggregate stays in InboxStorage forever. And re-delivered on each shard delivery iteration.

Steps to reproduce:

  1. Throw an exception in the @Apply method of the aggregate.
  2. Send FirstCommand to the aggregate and emit the event that will lead to the exception.
  3. Send SecondCommand to the aggregate and emit the event that will lead to the exception.
  4. Send one more command with the same ShardIndex to another entity.

What happens:

  • Aggregate failed to apply the event and threw an exception;
  • Diagnostic event CannotDispatchDuplicateCommand thrown for SecondCommand.

What I expect:

  • Aggregate failed to apply the event and threw an exception;
  • ~~Diagnostic event CannotDispatchDuplicateCommand thrown for SecondCommand;~~
  • Another entity successfully handles the command.

dmytro-kashcheiev avatar Sep 27 '22 11:09 dmytro-kashcheiev