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
Nieder mit dem Spaghetti Code durch Statemachines
Search
Nicolas Byl
April 25, 2018
Technology
0
140
Nieder mit dem Spaghetti Code durch Statemachines
Nicolas Byl
April 25, 2018
Tweet
Share
More Decks by Nicolas Byl
See All by Nicolas Byl
Platform Engineering ❤️ Developer Experience
nbyl
0
22
Die Flucht aus der Prototypen-Hölle
nbyl
0
45
Lean Prototyping for Industrial-IoT Projects
nbyl
0
56
DevSecOps - Vom Unikum zur gut geölten Maschine
nbyl
0
110
Securing your software supply chain
nbyl
0
370
Keeping-Up-WithUpstream.pdf
nbyl
0
170
Dr. Kube und der Helm - Anatomie einer CD-Pipeline
nbyl
0
130
Securing the "other" supply chain
nbyl
0
290
Kubernetes - Auf die Cluster, Fertig, Los!
nbyl
0
200
Other Decks in Technology
See All in Technology
2025年 山梨の技術コミュニティを振り返る
yuukis
0
140
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
17k
Authlete で実装する MCP OAuth 認可サーバー #CIMD の実装を添えて
watahani
0
380
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
12k
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
820
あの夜、私たちは「人間」に戻った。 ── 災害ユートピア、贈与、そしてアジャイルの再構築 / 20260108 Hiromitsu Akiba
shift_evolve
PRO
0
330
Everything As Code
yosuke_ai
0
480
LayerX QA Night#1
koyaman2
0
300
人工知能のための哲学塾 ニューロフィロソフィ篇 第零夜 「ニューロフィロソフィとは何か?」
miyayou
0
310
AIエージェントを5分で一気におさらい!AIエージェント「構築」元年に備えよう
yakumo
1
130
AI駆動開発ライフサイクル(AI-DLC)の始め方
ryansbcho79
0
290
スクラムを一度諦めたチームにアジャイルコーチが入ってどう変化したか
kyamashiro73
0
110
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.2k
Mind Mapping
helmedeiros
PRO
0
45
Testing 201, or: Great Expectations
jmmastey
46
7.8k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
720
Embracing the Ebb and Flow
colly
88
4.9k
The Spectacular Lies of Maps
axbom
PRO
1
410
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
110
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
0
48
Accessibility Awareness
sabderemane
0
29
Rails Girls Zürich Keynote
gr2m
95
14k
Designing for Timeless Needs
cassininazir
0
110
Transcript
1 NIEDER MIT DEM SPAGHETTI CODE DURCH STATEMACHINES JAX 2018
Nicolas Byl, codecentric AG
2 . 1 EINLEITUNG
None
2 . 2
2 . 3 2 . 4 Wer hat bereits eine
State Machine implementiert?
if (order.getState() == State.COMMISSIONED) { order.setState(State.SHIPPED); order.save(); }
2 . 5 2 . 6 Nochmal: Wer hat bereits
eine State Machine implementiert?
3 . 1 STATE MACHINES
3 . 2 Ein Beispiel Downloading docker pull Blocked docker
create Image is pulled Dependencies satisfied Pending Starting docker start Ready Throttling policy LivenessProbe reports its first OK Failed Time-out
3 . 3 Zustandsänderungen
3 . 4 DISTRIBUTED BALL OF MUD https://commons.wikimedia.org/wiki/File:Taylor%27s_Dorodango_cropped.jpg
3 . 5 Zustandsänderungen konzentrieren
4 . 1 SPRING STATE MACHINES
4 . 2 Spring State Machines State Machine Library Spring
Integration Event-basiert
4 . 3 Integration <dependencies> <dependency> <groupId>org.springframework.statemachine</groupId> <artifactId>spring-statemachine-core</artifactId> <version>1.2.8.RELEASE</version> </dependency>
</dependencies>
4 . 4 Konfiguration @Configuration @EnableStateMachine public class StateMachineConfig extends
EnumStateMachineConfigurerAda @Override public void configure(StateMachineStateConfigurer<CheckStatus, Ch states .withStates() .initial(CheckStatus.Initializing) .states(EnumSet.allOf(CheckStatus.class)); }
4 . 5 Konfiguration (2) @Override public void configure(StateMachineTransitionConfigurer<CheckStatu transitions
.withExternal() .source(CheckStatus.Initializing).target(CheckStatus. .and() .withExternal() .source(CheckStatus.Initializing).target(CheckStatus. .and() [...]; } }
4 . 6 Events auslösen stateMachine.sendEvent(CheckEvents.succeeded);
4 . 7 Zustandsänderungen überwachen @WithStateMachine static class MyBean {
@OnTransition(target = CheckStatus.Operational) void enteredOperational() { } @OnStateChanged public void checkStatusChanged(StateContext<CheckStatus, CheckEve } }
5 . 1 DEMO TIME
5 . 2 Monitoring Demo Monitoring von lokalen Dateien Alarmierung
wenn zwei Checks in Folge fehlschlagen
5 . 3 State Machine
5 . 4 Demo Project https://github.com/nbyl/spring-state-machine-demo
6 . 1 SPRING STATE MACHINE
6 . 2 Advanced Features Verteilte State Machines mittels Zookeeper
Scoping Security State Persistence
7 . 1 THE END Copyright 2018