The application I work on use a command bus to handle events (REST API HTTP requests, commande line interface). This bus is built using the well known league/tactician package.

Feature to implement

Now, I need to send an email notification to my users when documents are shared.

At the REST API level, the client ask to share N documents to M users. At the Application level, the command can only share one document to one user.

We want the user only receive a single email with information about all documents he gain access to.

Architectural idea

To implement this feature, I would use two new command bus middleware.

The first one (CollectNotifications) will listen the command bus to track which commands successfully executed and keep it in memory if we want to send a notification about this command.

The second one (SendNotifications) will be execute when the command bus is empty (I use the LockingMiddleware)

My command bus middleware chain now looks like this:


This approach could only work if looping over the documents and users to send commands is done as a command itself.


Is this architecture make sense?

What about having a command which job is just to spawn more smaller commands ?

Would you do it differently?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.