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
72
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
110
Monitoring your Application
magnusnordlander
0
370
Git Internals for PHP Developers
magnusnordlander
0
150
HttpFoundation – An excursion in a Symfony2 component
magnusnordlander
1
90
The GIt object model and using Gittern
magnusnordlander
2
1.4k
Other Decks in Programming
See All in Programming
Micro Frontends for Java Microservices - Utah JUG 2024
mraible
PRO
1
110
Webアプリをできるだけコードを手書きしないで作ってみる
tomokusaba
2
190
仕様と実装で学ぶOpenTelemetry
drumato
0
120
Go製Webアプリケーションのエラーとの向き合い方大全、あるいはやっぱりスタックトレース欲しいやん / Kyoto.go #50
utgwkk
6
1.9k
新宿ダンジョンを可視化してみた
satoshi7190
3
420
Try creating your own orderedmap
kazamori
1
270
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
1k
Open AI APIを使う前に知っておきたいアカウントTier の話
akki_megane
0
110
Hanami and htmx
bkuhlmann
0
230
AmperとFleetを使ったAndroidアプリ
yoppie
0
280
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
930
Goのエラースタックトレースの歴史と今後
sonatard
10
2k
Featured
See All Featured
Building an army of robots
kneath
300
41k
Web Components: a chance to create the future
zenorocha
306
41k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
8
3.4k
VelocityConf: Rendering Performance Case Studies
addyosmani
321
23k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
12
1k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
126
32k
Principles of Awesome APIs and How to Build Them.
keavy
121
16k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
66
14k
Designing the Hi-DPI Web
ddemaree
276
33k
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?