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
110
Nieder mit dem Spaghetti Code durch Statemachines
Nicolas Byl
April 25, 2018
Tweet
Share
More Decks by Nicolas Byl
See All by Nicolas Byl
Die Flucht aus der Prototypen-Hölle
nbyl
0
24
Lean Prototyping for Industrial-IoT Projects
nbyl
0
18
DevSecOps - Vom Unikum zur gut geölten Maschine
nbyl
0
75
Securing your software supply chain
nbyl
0
280
Keeping-Up-WithUpstream.pdf
nbyl
0
100
Dr. Kube und der Helm - Anatomie einer CD-Pipeline
nbyl
0
89
Securing the "other" supply chain
nbyl
0
210
Kubernetes - Auf die Cluster, Fertig, Los!
nbyl
0
120
Helm - Kubernetes Deployments richtig gemacht
nbyl
0
100
Other Decks in Technology
See All in Technology
サービス開発を前に進めるために 新米リードエンジニアが 取り組んだこと / Steps Taken by a Novice Lead Engineer to Advance Service Development
nologyance
0
180
AWSサービスメニュー開発をしていてAWSを好きだ!と感じた瞬間
toru_kubota
0
130
エンジニア向け会社紹介資料
caddi_eng
14
220k
累計ダウンロード数1億8000万を超えるアプリケーションプラットフォームのレガシーシステム脱却とモダン化への道
kmitsuhashi
0
120
Git 研修 Advanced【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
200
Azure OpenAI Service Dev Day / LLMでできる!使える!生成AIエージェント
masahiro_nishimi
3
750
データ分析を支える技術 生成AI再入門
ishikawa_satoru
0
380
Amazon FSx for NetApp ONTAPのパフォーマンスチューニング要素をまとめてみた #cm_odyssey #devio2024
non97
0
220
20240717_イケコパ代表Copilot_in_Teams会社でこう使ってます
ponponmikankan
2
430
Matterport を使ってクラスメソッド各拠点のバーチャルオフィスツアーを作成してみた
wakatsuki
0
160
地理情報とAPIのトレンド
nagix
0
160
AWS IAMのアンチパターン/AWSが考える最低権限実現へのアプローチ概略(JAWS-UG朝会#59資料改修20分版)
htan
0
330
Featured
See All Featured
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
105
6.8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
17
8.7k
Optimizing for Happiness
mojombo
373
69k
It's Worth the Effort
3n
181
27k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
12
3.8k
What the flash - Photography Introduction
edds
65
11k
Designing the Hi-DPI Web
ddemaree
276
34k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
23
1.9k
WebSockets: Embracing the real-time Web
robhawkes
59
7.2k
The Mythical Team-Month
searls
217
43k
Rails Girls Zürich Keynote
gr2m
93
13k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
16
1.6k
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