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
76
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
450
Git Internals for PHP Developers
magnusnordlander
0
190
HttpFoundation – An excursion in a Symfony2 component
magnusnordlander
1
99
The GIt object model and using Gittern
magnusnordlander
2
1.5k
Other Decks in Programming
See All in Programming
WebDriver BiDiとは何なのか
yotahada3
1
140
GitHub Actions × RAGでコードレビューの検証の結果
sho_000
0
260
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
740
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
130
ファインディLT_ポケモン対戦の定量的分析
fufufukakaka
0
710
定理証明プラットフォーム lapisla.net
abap34
1
1.8k
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
4
390
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
47
17k
Lottieアニメーションをカスタマイズしてみた
tahia910
0
130
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
190
Amazon S3 TablesとAmazon S3 Metadataを触ってみた / 20250201-jawsug-tochigi-s3tables-s3metadata
kasacchiful
0
160
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
Featured
See All Featured
Music & Morning Musume
bryan
46
6.3k
For a Future-Friendly Web
brad_frost
176
9.5k
Facilitating Awesome Meetings
lara
52
6.2k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
174
51k
A Tale of Four Properties
chriscoyier
158
23k
Making Projects Easy
brettharned
116
6k
A designer walks into a library…
pauljervisheath
205
24k
Visualization
eitanlees
146
15k
Testing 201, or: Great Expectations
jmmastey
42
7.2k
The Cult of Friendly URLs
andyhume
78
6.2k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
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?