Hi I have a following scenario,
There is two seperate application
- ShopManagament - This handle the registration of shop. Contaning aggregate Shop and other aggregates
- NotifyService - This send the mail , sms , notification. Contaning aggregate Email , SMS , Nofication
The both application build using CQRS/ES with DDD.
Technology used to build the application is Spring with Axon and for messaging usign RabbitMQ
Step 1 -
A shop is registered by issue a command ShopRegisrtraionCommand (ofcourse this handle by the shop aggregate and change the status when event is fired) , which fire an event ShopRegistratedEvent .
Step 2 -
When shop ShopRegistredEvent is fired , then I have a EventHandler which listen ShopRegistredEvent and send the SendEmailVerificationCommand (you can say a request or it act as request )to NotifyService.
Step 3 -
The same command (SendEmailVerificationCommand ) is also handle by the Shop aggregate and then shop aggregates fire an event MailVerifcationSendedEvent, this event changes the verification status of Shop to "MailInSendingProcess".
Step 4 - On other side NotifyService handle that command (SendEmailVerificationCommand or request ) and send the mail , if the email successfully sent then NotifyService fire a VerificationEmailSent.
Step 5 -
VerificationEmailSentEvent (fired by NotifyService) is listen by ShopManagment Application using the event listener , then this event listener issue a VerificationMailSendedSuccesfullyCommand for the shop aggregates, and then shop aggregate fire an event VerificationEmailDeliveredEvent , this changes the verifcation status "MailDelivered".
Step 6 -
If the mail sending failed due to any reasons , NotifyService fire another event VerificationEmailSendingUnsuccessfullEvent which handle by ShopManagament event listener and issue a another command VerificationEmailUnsuccessfull to shop aggregate and then shop aggregate fire an event VerficationMailSendingFailedEvent , this event change the status of verification status to "MailSendingFalied".
Here the two BC communicate using request and event.
Question -
- Can we send command to other bounded context as I am sending in my application or there is another approach.
- Is the tracking the status of the Email sending is part of Shop aggregate or I have to create the another aggregate like EmailVerifcation because I have to resend the falied mail using the schedular.
- Is any other way to manage this type of thing if happinning?