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
77
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
130
Monitoring your Application
magnusnordlander
0
480
Git Internals for PHP Developers
magnusnordlander
0
200
HttpFoundation – An excursion in a Symfony2 component
magnusnordlander
1
100
The GIt object model and using Gittern
magnusnordlander
2
1.5k
Other Decks in Programming
See All in Programming
アンドパッドの Go 勉強会「 gopher 会」とその内容の紹介
andpad
0
260
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
100
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
210
Code as Context 〜 1にコードで 2にリンタ 34がなくて 5にルール? 〜
yodakeisuke
0
100
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
1
520
Team operations that are not burdened by SRE
kazatohiei
1
200
20250628_非エンジニアがバイブコーディングしてみた
ponponmikankan
0
390
Gleamという選択肢
comamoca
6
760
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
120
Rubyでやりたい駆動開発 / Ruby driven development
chobishiba
1
370
GraphRAGの仕組みまるわかり
tosuri13
7
480
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
1
120
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
24
1.7k
How STYLIGHT went responsive
nonsquared
100
5.6k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
Building Applications with DynamoDB
mza
95
6.5k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Designing Experiences People Love
moore
142
24k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.8k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
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?