CQRS - Domain Exceptions Vs Events for Exceptional Scenarios -
i'm wondering if it's preferable publish events rather throw exceptions aggregates. say, have domain there requirement students of grade level can enroll sports. if call enrollforsports on student not satisfy criteria, should aggregate throw exception or publish event, particularly if other aggregates or process managers interested in result of process?
if event published, doesn't mean there need corresponding internal event handler handle event when we're replaying, though event wouldn't change state of aggregate?
if exception thrown, how other parties notified? can command handler catch exception , raise event? can events raised command handlers?
principally speaking, command should either valid , executed, or invalid , not executed. idea spawning error events leaves somewhere in middle , feedback whomever sends command ambiguous , delayed. unnecessary complexity in domain. if throw exception come immediate feedback to client code sent command.
Comments
Post a Comment