Re: Exceptions in event handlers

"Joseph Flood [email protected] [domaindrivendesign]" <[email protected]> Tue, 21 Apr 2015 09:18:19 +1000
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <CAOg4kjEnph9J376Arx5zr9zNKZL+DQb2pryc-vK_8rWJmpikyg@mail.gmail.com>
You can use process managers for this. They respond to events and issue
commands to other aggregates. They may even cross boundaries ( or live in
their own context). If compensating action is required, you can build this
into the process manager.
On 21 Apr 2015 12:02 am, "[email protected] [domaindrivendesign]" <
[email protected]> wrote:


>
>
> How should one handle exceptions in events handlers when doing DDD?
>
>
> As a very simplistic example I want Aggregate2 to react to events raised
> byAggregate1. However Aggregate2 may throw an exception during the event
> processing and the system is now in an invalid state.
>
>
> I think I read somewhere that a compensating command should be issued;
> however, doesn't that lead to scattered compensating command all over the
> code base?
>
>
> Moreover, Aggregate2 may be in another bounded context and may now it
> needs to know how to issue a command to another BC to fix its error (which
> may also fail :D)
>
>
> Is there a practical way to handle errors in event handlers?
>  
>