dimanche 8 juillet 2018

Can application services call other application services within a bounded context in DDD?

Domain events are a great way to propagate that something happened so that something else can happen later. As I understand it, it's great to use domain events across bounded contexts.

Let's say we are creating a Q and A site like Stack Overflow. There are users that post questions, and questions can be closed.

Here are some possible commands in such an application:

  • Ask question
  • Close question
  • Ban user

Domain requirements state that if a user is banned, all their questions must be closed.

When a fraud detection service detects that a user is a fraud, the user should be banned and all his questions closed. Can this fraud detection service call the ban user service, which in turn calls the close all of user's questions service?

We wouldn't want to duplicate all the "closing" logic we already made. Is it only recommended to dispatch events like "UserBannedEvent", and have a listener call the close all of user's questions application service? Or can one just call another?

Aucun commentaire:

Enregistrer un commentaire