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
Fundamental Domain-Driven Design For Microservices
Search
Oliver Drotbohm
April 19, 2016
Programming
11
1k
Fundamental Domain-Driven Design For Microservices
Slides of the talk I gave at JAX 2016, Mayence.
@springcentral
Oliver Drotbohm
April 19, 2016
Tweet
Share
More Decks by Oliver Drotbohm
See All by Oliver Drotbohm
It Takes Two to Tango – Designing Module Interactions in Modulithic Spring Applications
olivergierke
4
430
Bottom-Up Architecture – Bridging the Achitecture Code Gap
olivergierke
4
700
Spring Modulith – A Deep Dive
olivergierke
7
3.7k
Spring for the Architecturally Curious Developer
olivergierke
5
1.7k
Spring Boot 3 & Spring Framework 6
olivergierke
4
1.9k
Architecturally-evident Java Applications with jMolecules
olivergierke
8
2.7k
A Deep Dive into Spring Application Events
olivergierke
12
3.1k
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
4
870
Spring HATEOAS – Hypermedia APIs with Spring
olivergierke
1
650
Other Decks in Programming
See All in Programming
デプロイを任されたので、教わった通りにデプロイしたら障害になった件 ~俺のやらかしを越えてゆけ~
techouse
52
32k
Modern Angular: Renovation for Your Applications
manfredsteyer
PRO
0
210
Outline View in SwiftUI
1024jp
1
150
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
JaSST 24 九州:ワークショップ(は除く)実践!マインドマップを活用したソフトウェアテスト+活用事例
satohiroyuki
0
260
Macとオーディオ再生 2024/11/02
yusukeito
0
190
OpenTelemetryでRailsのパフォーマンス分析を始めてみよう(KoR2024)
ymtdzzz
4
1.6k
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
920
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
110
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
550
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.3k
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
4
1.6k
Featured
See All Featured
Optimizing for Happiness
mojombo
376
69k
Why Our Code Smells
bkeepers
PRO
334
57k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Happy Clients
brianwarren
97
6.7k
Automating Front-end Workflow
addyosmani
1365
200k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Docker and Python
trallard
40
3.1k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
A Modern Web Designer's Workflow
chriscoyier
692
190k
A designer walks into a library…
pauljervisheath
202
24k
Transcript
© 2014 SpringOne 2GX. All rights reserved. Do not distribute
without permission. DOMAIN-DRIVEN DESIGN / OLIVERGIERKE ƻ
[email protected]
GRUNDLEGENDES FÜR MICROSERVICES
2
None
4 http://www.infoq.com/minibooks/domain-driven-design-quickly
Microservices ♥ Domain-Driven Design 5 Slides and video by Michael
Plöd.
6
6
Implementing Domain-Driven Design 7
Value objects 8
Stringly typed code 9 public class Customer { private Long
id; private String firstname, lastname, email; … }
Stringly typed code 10 public class SomeService { public void
createUser(String firstname, String lastname, String email) { … } }
11 public class Customer { private Long id; private Firstname
firstname; private Lastname lastname; private EmailAddress emailAddress; … }
Value Objects are a PITA to build in some languages.
12
Still, they’re worth it. 13 See „Power Use of Value
Objects in DDD“ by Dan Bergh Johnsson.
Lombok — putting the spice back into Java. 14
15 @Value public class Customer { UUID id = UUID.randomUUID();
Firstname firstname; Lastname lastname; EmailAddress email; @Value static class EmailAddress { String value; } }
AutoValue 16 Project website on GitHub.
Key opponents: Mapping libraries that need to (de)serialize them. 17
Entities & Aggregates 18
Persistence technology VS. Domain model 19
Challenges with JPA: Value objects as @Entity Flat relationships
20
21 Order LineItem Product Invoice Customer Payment Address Email
21 Order LineItem Product Invoice Customer Payment Address Email
Repositories turn an entity into an aggregate root. 22
23 Order LineItem Product Invoice Customer Payment Address Email
Bounded Context 24
Order LineItem Product Invoice Customer Payment Address
26 Shipping Accounting Catalog Orders User Registration
26 Shipping Accounting Catalog Orders User Registration Accounting Payment information
Billing Address Shipping Shipping address Customer
26 Shipping Accounting Catalog Orders User Registration Accounting Payment information
Billing Address Shipping Shipping address Customer Product
Domain-Driven Design & Monoliths 27
Avoid technologies that get in your way. 28
How to enforce context boundaries? 29
What about consistency? 30
References between Bounded Contexts? 31
Domain Events 32
33 Level 0: No events at all
33 Level 0: No events at all Level 1: Explicit
operations
If you’re calling two setters in a row, you’re missing
a concept. 34
35 Level 0: No events at all Level 1: Explicit
operations
35 Level 0: No events at all Level 1: Explicit
operations Level 2: Some operations as events
State transitions become domain events. 36
37 Level 0: No events at all Level 1: Explicit
operations Level 2: Some operations as events
37 Level 0: No events at all Level 1: Explicit
operations Level 2: Some operations as events Level 3: Event Sourcing
Domain-Driven Design & Microservices 38
Bounded contexts define system boundaries. 39
40 Shipping Accounting Catalog Orders User Registration Accounting Payment information
Billing Address Shipping Shipping address Customer Product
41 Shipping Accounting Catalog Orders User Registration Accounting Shipping
42 Shipping Accounting Catalog Orders User Registration Accounting Shipping HTTP
Messaging
Architecture is less likely to deteriorate as it’s harder to
violate boundaries. 43
Restructuring service boundaries is much harder. 44
Inter-Service communication becomes remote communication. 45
Accept and embrace eventual consistency between services. 46
Domain Events 47
REST & Messaging 48
Domain events become state transitions. 49
Hypermedia for state transition and explicit events. 50
Thanks! 51