Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Buses
Search
Magnus Nordlander
October 19, 2015
Programming
0
75
Buses
Command buses and Event buses
Magnus Nordlander
October 19, 2015
Tweet
Share
More Decks by Magnus Nordlander
See All by Magnus Nordlander
How Fervo builds web apps
magnusnordlander
0
120
Monitoring your Application
magnusnordlander
0
430
Git Internals for PHP Developers
magnusnordlander
0
180
HttpFoundation – An excursion in a Symfony2 component
magnusnordlander
1
93
The GIt object model and using Gittern
magnusnordlander
2
1.4k
Other Decks in Programming
See All in Programming
offers_20241022_imakiire.pdf
imakurusu
2
360
デプロイを任されたので、教わった通りにデプロイしたら障害になった件 ~俺のやらかしを越えてゆけ~
techouse
52
32k
Vue.js学習の振り返り
hiro_xre
2
130
Vaporモードを大規模サービスに最速導入して学びを共有する
kazukishimamoto
4
4.3k
CSC509 Lecture 08
javiergs
PRO
0
100
色々なIaCツールを実際に触って比較してみる
iriikeita
0
260
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
1.6k
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
400
RailsのPull requestsのレビューの時に私が考えていること
yahonda
5
1.7k
Server Driven Compose With Firebase
skydoves
0
390
現場で役立つモデリング 超入門
masuda220
PRO
12
2.9k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
950
Featured
See All Featured
Optimizing for Happiness
mojombo
376
69k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
3
370
Building Applications with DynamoDB
mza
90
6.1k
Embracing the Ebb and Flow
colly
84
4.4k
Teambox: Starting and Learning
jrom
132
8.7k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
Automating Front-end Workflow
addyosmani
1365
200k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
790
Why Our Code Smells
bkeepers
PRO
334
57k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
107
49k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Transcript
Buses Command buses and Event buses
Magnus Nordlander • PHP consultant specializing in Symfony • Working
at Fervo
Hybrid Bus RTB by Kecko https://www.flickr.com/photos/kecko/8217510887/
Foro Romano by Bert Kaufmann https://www.flickr.com/photos/22746515@N02/8043630550/
The three degrees of doing • Do it yourself •
Ask someone else to do it • Command it be done
Emperor Trajan at Tower Hill by DncnH https://www.flickr.com/photos/duncanh1/9548613224/
Commands • A command is a message which is imperative
in nature • ChangeUserPassword • SendWelcomeEmail
Commands • Always handled by exactly one handler • Task-oriented
• Never returns a value • Required for Command/Query Separation
Command handlers • Immutable services • Handles exactly one command
type each • Only performs the "primary" task related to the event • Remember SRP and OCP
Command bus libs • SimpleBus • Tactician • Broadway
Demo
Why? • Models changes in domain language, capturing intent •
ChangePassword vs UpdateUser • Maps very well to a Task oriented UI
Why? • Reinforces Command-Query Responsibility Separation (CQRS) • Asking a
question should not change the answer • Clearly indicates which code changes system state
Restrictive? • Only performs primary task • No return value
Events
Events • Events are messages which are informational in nature
• UserPasswordWasChanged • WelcomeEmailWasSent
Events • Handled by zero or more listeners • Always
after-the-fact • Cannot change what has already happened
Event listener • Immutable service • Acts upon one type
of event and performs some action • Should be called every time a pertinent event is handled • No listener should be able to stop propagation
Event listener • Example: • WhenNewUserSignedUpSendWelcomeEmail
Event bus libs • SimpleBus • Broadway • Symfony EventDispatcher
• Laravel EventDispatcher • League EventEmitter
Demo
Connecting the dots • Command handlers can emit events •
Event subscribers can issue commands
Learning more • Matthias Noback has a series of excellent
blog posts • http://php-and-symfony.matthiasnoback.nl/tags/ command%20bus/ • Also has a Hexagonal Symfony workshop
Questions?