Upgrade to Pro — share decks privately, control downloads, hide ads and more …

All aboard the Service Bus!

All aboard the Service Bus!

We deal with complicated and complex applications on a daily basis, codebases that are filled with classes that do too many things. One design pattern that can help us with this is CQRS, Command Query Responsibility Seggregation. The idea behind CQRS is to split our models in two - the Command for writing, and the Query for reading. Applying CQRS can lead us to a more maintainable code, code that follows the SOLID principles more closely.

At the heart of CQRS lies the Service Bus - a transport mechanism responsible for dispatching our command, event, and query messages to their destinations.

This talk will give an overview of the CQRS pattern and take a closer look at the different types of service buses - command, event, and query ones. Main takeaway will be practical information on why, when, and how to use them, with emphasis on their differences. We'll also take a look at some of the PHP libraries out there that help us work with service buses like Prooph Service Bus, Simple Bus, Tactician, to name a few.


June 08, 2018

More Decks by robertbasic

Other Decks in Programming


  1. All aboard the Service Bus! All aboard the Service Bus!

    Robert Basic Robert Basic @robertbasic @robertbasic https:/ /robertbasic.com/ https:/ /robertbasic.com/ 1
  2. Photo by Mike Erskine An introduction An introduction CQS &

    CQRS CQS & CQRS Service buses Service buses Command buses Command buses Event buses Event buses Query buses Query buses Recap Recap 3
  3. 6

  4. Smaller classes Smaller classes Separated responsibilities Separated responsibilities Faster writes

    and reads Faster writes and reads Easier database queries Easier database queries Photo by Aziz Acharki 10
  5. More classes More classes Translation Translation Complex syncing Complex syncing

    Eventual consistency Eventual consistency Photo by Daniel Páscoa 11
  6. 13

  7. Message type support Message type support Tactician Tactician SimpleBus SimpleBus

    Prooph Service Bus Prooph Service Bus Photo by Rob Allen 14
  8. 15

  9. Commands Commands Messages about user intention Messages about user intention

    CreateProduct, PutProductOnSale CreateProduct, PutProductOnSale Name reveals use case Name reveals use case One command, one action One command, one action 16
  10. 21

  11. Events Events Messages about past events Messages about past events

    After a command was handled After a command was handled ProductCreated, ProductPriceUpdated ProductCreated, ProductPriceUpdated Once dispatched, can’t be stopped Once dispatched, can’t be stopped 22
  12. 26

  13. Queries Queries Not the same as database queries Not the

    same as database queries A query is a question A query is a question LatestProductsCreated, ProductsOnSale LatestProductsCreated, ProductsOnSale Answers from read models Answers from read models 27
  14. Thank you! Thank you! Robert Basic Robert Basic @robertbasic @robertbasic

    https:/ /robertbasic.com/ https:/ /robertbasic.com/ https:/ /joind.in/talk/5a9d7 https:/ /joind.in/talk/5a9d7 33