Wrapping "Can one command cause multiple messages?"

If you went to a university before, say, 2010, do you remember the ride boards?

People going from the university town to some other place would post little notices of where they were going and how much they would charge for a ride.

You would walk by there every so often and see if there were any messages that interested you and react when there were.

That was pub/sub. It’s pretty simple.

Message stores provide pub/sub communication

In our model, when you see funds-transfer-component observing account-component’s events, understand it consumes those messages via pub/sub. It doesn’t really know where the events come from. It just knows they appeared in the right stream category and that they have the right metadata.correlation_stream_name, which it gets from how it starts its consumer:

Consumers::Account::Events.start('account', correlation: 'fundsTransfer') 

Once in the handler, it handles it like it would any message by:

  1. Figuring out which entity it’s dealing with
  2. Projecting the current state of the entity
  3. Seeing if it has already processed the message
  4. Doing and recording the work of processing the message

And that’s a wrap!

Thank you for the question all those days ago, Daniel. Yes, a single command can lead to more than one event and even more than one additional command.

Your workflows are what they are, and you design what it takes to handle them. If your design leads you to producing more than one message, that’s not even a design smell. It’s just part of the process.


Like this message? I send out a short email each day to help software development leaders build organizations the deliver value. Join us!


Get the book!

Ready to learn how to build an autonomous, event-sourced microservices-based system? Practical Microservices is the hands-on guidance you've been looking for.

Roll up your sleeves and get ready to build Video Tutorials, the next-gen web-based learning platform. You'll build it as a collection of loosely-coupled autonomous services, developing a message store interface along the way.

When you're done, you'll be ready to contribute to microservices-based projects.

In ebook or in print.