Can I dispatch events within domain service? -


i have userregistry bc. has accountservice contains methods accountid registeraccount(string username, string password) , void changepassword(accountid id, string newpassword). don't have ars because domain talks external service through acl , of operations handled external service. another bc needs able act on accountregistered , accountpasswordchanged events. actually, that's whole point of context - provide interface functionality , raise specific events whenever occur.

given information, can raise events in acl service? (actually, accountservice acl) or can raise them in application layer use acl? how can raise events without aggregate roots?

for now, have following implementation:

// external system integration service. interface iexternalsystem {     string register(string name, string password); }  // acl domain service. class accountservice {     accountid register(string name, string password)     {         return accountid.fromstring(             _externalsystem.register(name, password));     } }  // application layer service. can implemented command handlers. class accountapplicationservice {     accountid register(string name, string password)     {         var id = _accountservice.register(name, password);          // line under question.         _eventdispatcher.dispatch(new accountregistered(id, name));          return id;     } } 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -