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
実践して分かったJavaマイクロサービス開発 #JavaDayTokyo
Search
Shin Tanimoto
May 24, 2016
Programming
6
7.1k
実践して分かったJavaマイクロサービス開発 #JavaDayTokyo
Java Day Tokyo 2016
2016/05/24
Shin Tanimoto
May 24, 2016
Tweet
Share
More Decks by Shin Tanimoto
See All by Shin Tanimoto
クラウドネイティブ時代のコンテナ環境におけるJavaアプリケーションのメトリクス・ログ・トレースモニタリング
shintanimoto
5
2.2k
26 Java Years
shintanimoto
0
49
Let’s Have Fun with Reactive Programming, Using Reactor and WebFlux
shintanimoto
0
230
Monitoring and Visualizing Your (Micro)services
shintanimoto
0
340
現代に求められるJavaコミュニティとは / What should be the Java Community of Today?
shintanimoto
0
880
人生がときめく「学び」の魔法 / The Life-Changing Magic of Studying
shintanimoto
6
1.6k
業務で使いたいWebFluxによるReactiveプログラミング / Introduction to Reactive Programming using Spring WebFlux
shintanimoto
9
9.1k
from old Java to modern Java (2017) #jjug
shintanimoto
4
1.6k
Spring Cloud Sleuth + Zipkin with Elasticsearch #zipkin_jp
shintanimoto
1
1.2k
Other Decks in Programming
See All in Programming
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
270
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
たのしいparse.y
ydah
3
120
선언형 UI에서의 상태관리
l2hyunwoo
0
140
Jakarta EE meets AI
ivargrimstad
0
230
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
450
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
350
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
14 Years of iOS: Lessons and Key Points
seyfoyun
1
770
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
300
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
3
1k
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
200
Featured
See All Featured
Navigating Team Friction
lara
183
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
440
What's in a price? How to price your products and services
michaelherold
243
12k
Adopting Sorbet at Scale
ufuk
73
9.1k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Transcript
࣮ફ͔ͯͬͨ͠JavaϚΠΫϩαʔϏε։ൃ - What I learned about Microservices - #jdt2016_4E
୩ຊ ৺ Acroquest Technologyגࣜձࣾ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Who
am I? 2 • ୩ຊ ৺ (Shin Tanimoto) - Acroquest Technology גࣜձࣾ - Javaτϥϒϧγϡʔλʔ - ຊJavaϢʔβάϧʔϓװࣄ Twitter : @cero_t - Facebook : shin.tainmoto
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ࣭ 3
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ։ൃऀͷํʁ 4
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ϚΠΫϩαʔϏε ͲΕ͙Β͍ฉ͍ͨ͜ͱ͕͋Δʁ 5
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 1. ໊લΛฉ͍ͨ͜ͱ͋Δ 2. ֓ཁ͙Β͍͍ͬͯΔ 3. ։ൃͨ͜͠ͱ͕͋Δ 4. ӡ༻͍ͯ͠Δ 5. શʹϚελʔͨ͠ 6
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. No.5ʁ ؼ͍ͬͯͩ͘͞ʂʂ 7
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ϚΠΫϩαʔϏεͱʁ 8
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ϚΠΫϩαʔϏε খ͞ͳαʔϏεͷू߹ମͱͯ͠ ߏங͞ΕͨγεςϜͰ͋Δ 9
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ϚΠΫϩαʔϏε ࢦ͢ͷͰͳ͘ ݁ՌͰ͋Δ 10
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ϚΠΫϩαʔϏε ϓϩάϥϛϯάͷख๏Ͱͳ͍ 11
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ϚΠΫϩαʔϏε ઃܭɺ࣮ɺσϓϩΠɺӡ༻ͳͲ ଟذʹΘͨΔ֓೦Ͱ͋Δ 12
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ΦϥΠϦʔͷ ϚΠΫϩαʔϏε ΞʔΩςΫνϟ 13
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 1ষ ϚΠΫϩαʔϏε 2ষ ਐԽతΞʔΩςΫτ 3ষ αʔϏεͷ ɹɹϞσϧԽํ๏ 4ষ ౷߹ 5ষ ϞϊϦεͷׂ 6ষ σϓϩΠ 14 7ষ ςετ 8ষ ࢹ 9ষ ηΩϡϦςΟ 10ষ ίϯΣΠͷ๏ଇͱ ɹɹ γεςϜઃܭ 11ষ େنͳ ɹɹ ϚΠΫϩαʔϏε 12ষ ·ͱΊ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 1.1 ϚΠΫϩαʔϏεͱ 1.1.1 খ͘͞ɺ͔ͭ1ͭͷׂʹઐ೦ 1.1.2 ࣗੑ 1.2 ओͳར 1.2.1 ٕज़ҟ࣭ੑ 1.2.2 ճ෮ੑ 1.2.3 εέʔϦϯά 1.2.4 σϓϩΠͷ༰қੑ 1.2.5 ৫໘ͷҰக 1.2.6 ߹Մೳੑ 1.2.7 ަՄೳʹ͢ΔͨΊͷ࠷దԽ 15
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ϚΠΫϩαʔϏε ৫จԽʹ·ͰࢸΔ֓೦ 16
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 1. ϚΠΫϩαʔϏεԽͷऔΓΈ 2. ·ͣAPIԽ 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ 4. ϚΠΫϩαʔϏετϥΠΞϧୈೋ 5. ϚΠΫϩαʔϏετϥΠΞϧୈࡾ 6. ࠓޙɺऔΓΈ͍ͨ͜ͱ 7. ຊʹϚΠΫϩαʔϏε࠷ద͔ʁ 17 Table of contents
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 18 #1 ϚΠΫϩαʔϏεԽ ͷऔΓΈ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 1. ϚΠΫϩαʔϏεԽͷऔΓΈ ରͷγεςϜ ECαΠτ ߪೖϖʔδ όοΫΤϯυͷγεςϜ ߏ Java SE 6 JBoss AS 6 Struts2 Hibernate3 MySQL 5.1 19
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. Start simple, not small 20
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ঃʑʹߏมߋ 1. αʔόαΠυϨϯμϦϯάܥͷγεςϜ ɹɹˣ 2. ߪೖαΠτΛHTML5 + WebAPIʹׂ ɹɹˣ 3. όοΫΤϯυγεςϜΛϚΠΫϩαʔϏεԽ ɹɹˣ 4. ཧը໘ΛϚΠΫϩαʔϏεԽ ɹɹˣ 5. ߪೖαΠτΛϚΠΫϩαʔϏεԽ 21 1. ϚΠΫϩαʔϏεԽͷऔΓΈ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 22 #2 ·ͣAPIԽ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 2. ·ͣAPIԽ ͬͨ͜ͱ 1. Struts2 + Hibernateͷ αʔόαΠυϨϯμϦϯάܥγεςϜΛɺ Angular1 + SpringMVCͰWeb APIԽ 2. AWS্Ͱ։ൃ/ߏங 3. యܕతͳτϥϯβΫγϣϯεΫϦϓτ • Controller • Service • Dao 23
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 2. ·ͣAPIԽ ྑ͔ͬͨ͜ͱ 1. ը໘ͱAPIͰɺશͳۀ͕Ͱ͖ͨ 2. Ұ෦ͷ͍ॲཧʹɺը໘શମͷඳը͕ Ҿ͖ͣΒΕΔ͜ͱ͕ͳ͘ͳͬͨ 3. ݕࡧAPIΛ࠶ར༻ͯ͠ɺ ผͷը໘Λ࡞͢Δ͜ͱ͕Ͱ͖ͨɻ 24
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 2. ·ͣAPIԽ ࣦഊͨ͜͠ͱ 1. APIΛը໘ʹಛԽ͗ͨ͢͠ʢ࠶ར༻ͮ͠Β͍ʣ • ใɺࡏݿɺྉۚΛɺ·ͱΊͯฦ͢API • ͨͿΜ͜ΕAPIԽ͋Δ͋Δͩͱࢥ͏ 2. ങ͍͔͝ΛηογϣϯʹೖΕͨ • εςΟοΩʔηογϣϯʹͤ͟ΔΛಘͣɺ ࠶σϓϩΠɺεέʔϧΞτɺεέʔϧΠϯ͕ ͮ͠Β͍ߏʹͳͬͯ͠·ͬͨɻ 25
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 2. ·ͣAPIԽ ࠔͬͨ͜ͱ 1. APIαʔόͷεέʔϧΞτ • APIαʔόΛ૿ͨ͢ͼʹɺ • Webαʔό (nginx) ͷઃఆΛ • ॻ͖͑ͳ͍͚ͯ͘ͳ͍ɻ ɹˠ WebαʔόlocalhostͷAPIαʔόͷΈʹ ɹɹసૹ͢ΔܗͰɺWeb + APIͷηοτͰ૿͢ɻ 26
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 2. ·ͣAPIԽ ࠔͬͨ͜ͱ 2. ٸʹʮॲཧΛඇಉظʹ͢Δʯͱ͍͏ཁ͕݅ු্ • ඇಉظʹ͢ΔͨΊͷΞϨίϨ༻ҙͯ͠ͳ͍Αʁ ɹˠ γϦΞϥΠζͯ͠ϑΝΠϧʹॻ͖ग़ͯ͠ɺ ɹɹͦΕΛඇಉظଆͷॲཧͰఆظಡΈࠐΈ͢Δ ɹɹͱ͍͏ݪ࢝తͳํ๏Λར༻ɻ 27
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 2. ·ͣAPIԽ ࣍ʹ͚ͯ 1. APIΛը໘ʹಛԽ͗ͨ͢͠ • ϚΠΫϩαʔϏεͱ͍͏ݴ༿͕͋ΔΒ͍͠ɻಋೖ͍ͨ͠ɻ 2. ങ͍͔͝ΛηογϣϯʹೖΕͨ • εςʔτϨεߏʹ͍ͨ͠ 3. APIαʔόͷεέʔϧΞτ • ϩʔυόϥϯγϯάͷपΓΛࣗಈԽ͍ͨ͠ 4. ٸʹʮॲཧΛඇಉظʹ͢Δʯͱ͍͏ཁ͕݅ු্ • ඇಉظॲཧͷΈΛඪ४Խ͍ͨ͠ 28
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 29 #3 ϚΠΫϩαʔϏε τϥΠΞϧୈҰ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͬͨ͜ͱ 1. όοΫΤϯυͷॲཧΛϚΠΫϩαʔϏεͰ࡞ • ใαʔϏεɺࡏݿαʔϏεɺྉۚαʔϏ εͳͲʹׂ 2. ٕज़ελοΫ • Spring Bootʢ1.2ܥʣ • Spring Cloudʢޙड़ʣ 30
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͬͨ͜ͱ 1. όοΫΤϯυͷॲཧΛϚΠΫϩαʔϏεͰ࡞ • ใαʔϏεɺࡏݿαʔϏεɺྉۚαʔϏεͳͲʹׂ 2. ॲཧͷڞ௨Խ • ಉظ HTTPʢΓ͋Γʣ • ඇಉظ AMQPʢΓͳ͠ʣ • RabbitMQΛ࠾༻ • ඇಉظ AMQPʢΓ or ίʔϧόοΫؔʣ • ඇಉظ HTTPʢΓ or ίʔϧόοΫؔʣ • ͜ΕΒར༻͠ͳ͍ 31
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 1. ಉظॲཧɺඇಉظॲཧͱʹɺ ґଘΛ໌֬Խ͢Δ 32 ItemAccessor (Client) ItemController (Server) HTTP AMQP
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 1. ಉظॲཧɺඇಉظॲཧͱʹɺ ґଘΛ໌֬Խ͢Δ 33 ItemService (interface) ItemAccessor (Client) ItemController (Server) HTTP AMQP implements implements
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 1. ಉظॲཧɺඇಉظॲཧͱʹɺ ґଘΛ໌֬Խ͢Δ • ΫϥΠΞϯτଆɺαʔόଆͷίϯτϩʔϥ͕ ಉ͡ΠϯλϑΣʔεΛ࣮͢Δ͜ͱͰɺ IDEͷOpen Call HierarchyʹΑΔ ݺͼग़͠ͷτϨʔε͕Ͱ͖Δ 34
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 2. αʔϏεσΟεΧόϦʢEurekaʣͷಋೖ • Netflix͕ࣾOSSͰఏڙ͍ͯ͠Δ αʔϏεσΟεΧόϦͷΈ • ಈతʹ͑ΔDNSతͳͷ 35
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 2. αʔϏεσΟεΧόϦʢEurekaʣͷಋೖ 36 Eureka Server ItemAccessor (Client) ItemController (Server) ᶃىಈ࣌ʹࣗͷ ɹϗετ໊ͱ ɹϙʔτ൪߸Λొ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 2. αʔϏεσΟεΧόϦʢEurekaʣͷಋೖ 37 Eureka Server ItemAccessor (Client) ItemController (Server) ᶄhttp://item-service/ ɹΛ͍ձΘͤ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 2. αʔϏεσΟεΧόϦʢEurekaʣͷಋೖ 38 Eureka Server ItemAccessor (Client) ItemController (Server) ᶅItemServiceͷ ɹϗετ໊ͱ ɹϙʔτ൪߸Λ ɹฦ͢ʢෳՄʣ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 2. αʔϏεσΟεΧόϦʢEurekaʣͷಋೖ 39 Eureka Server ItemAccessor (Client) ItemController (Server) ᶆड͚औͬͨใͰ ɹΞΫηε
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 2. αʔϏεσΟεΧόϦʢEurekaʣͷಋೖ • αʔϏεΛʮԿʯʮͲͷαʔόͰʯ ʮͲͷϙʔτͰʯىಈͯ͠ྑ͍ ɹˠ εέʔϧͷࣗ༝Խ • Spring Boot + Spring CloudΛ͏͜ͱͰ ߦͷઃఆ͚ͩͰར༻Մʢʂʣ 40
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 3. JUnitͷൣғΛ໌֬Խ • ControllerҎ߱ͷςετʢJUnitʣ • αʔϏεͷػೳ୯ମςετ • αʔϏε୯ମͰͷend-to-endͷςετʢJUnit) • Spring BootͳΒJUnitͰ؆୯ʹͰ͖Δ • ओʹมͱόϦσʔγϣϯͷࢼݧ • ֎෦αʔϏεݺͼग़͠෦ϞοΫԽ 41
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 3. JUnitͷൣғΛ໌֬Խ • ෳαʔϏεͷςετʢJUnitʣ • ֎෦αʔϏεݺͼग़͢ 42
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ 43 ItemService (interface) ItemAccessor (Client) ItemController (Server) HTTP AMQP implements implements LogicΫϥε
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ 44 TestCase ItemController (Server) LogicΫϥε ᶃΠϯελϯε ɹ࡞ ᶄItemServiceͷϞοΫͱͯ͠DI
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ 45 TestCase ItemController (Server) LogicΫϥε ᶅݺͼग़͢
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ͨ͜͠ͱ 4. σϓϩΠͷࣗಈԽ • ܰ͘࡞͚ͬͨͩͰɺेͷαʔϏε͕͋ΔͷͰ σϓϩΠͷࣗಈԽඞਢ • ansibleΛར༻ʢchef࠳ંɾɾɾʣ • AWSͰ͍ͬͯΔҎ্docker ͦΜͳʹϝϦοτ͕ͳ͍ͱࢥ͍ͬͯΔ 46
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ྑ͔ͬͨ͜ͱ 1. ࣗ༝ͳεέʔϧΠϯɺεέʔϧΞτ͕Ͱ͖ɺ ϩʔυόϥϯγϯά·ͰͰ͖ΔΑ͏ʹͳͬͨɻ 2. αʔϏεͷϗετ໊ϙʔτ൪߸Λ શ͘ཧ͠ͳͯ͘ྑ͘ͳͬͨ 3. ಉظɺඇಉظͷ։ൃͱςετͷ ඪ४తͳΓํ͕ܾ·ͬͨ 47
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ࣦഊͨ͜͠ͱ 48
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ࣦഊͨ͜͠ͱ ಛʹͳ͠ → શʹϚΠΫϩαʔϏεΛϚελʔͨ͠ײ☺️ 49
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 3. ϚΠΫϩαʔϏετϥΠΞϧୈҰ ࣦഊͨ͜͠ͱ ಛʹͳ͠ → શʹϚΠΫϩαʔϏεΛϚελʔͨ͠ײ☺️ ɾɾɾͱࢥͬͨΒɺ࣍ͷ։ൃͷ࣌ʹ ࠓճ࡞ͬͨϚΠΫϩαʔϏε͕ Ζ͘ʹ࠶ར༻Ͱ͖ͳ͔ͬͨ 50
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 51 #4 ϚΠΫϩαʔϏε τϥΠΞϧୈೋ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 4. ϚΠΫϩαʔϏετϥΠΞϧୈೋ ͬͨ͜ͱ 1. ཧը໘ͷϚΠΫϩαʔϏεԽ • ใαʔϏεɺࡏݿαʔϏεɺ ྉۚαʔϏεͳͲΛ࠶։ൃ 2. ٕज़ελοΫ • Spring Bootʢ1.3ܥʣ • Spring Cloud 52
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 4. ϚΠΫϩαʔϏετϥΠΞϧୈೋ ࠔͬͨ͜ͱ 1. ୈҰͰ͍ٕͬͯͨज़ελοΫͱͷޓੑ • ୈҰ : Spring Boot 1.2 + Spring Cloud Angel • ୈೋ : Spring Boot 1.3 + Spring Cloud Brixton ɹˠ AngelͷEurekaʹ ɹɹBrixtonͷαʔϏεΛొͰ͖ͳ͍ ɹˠ BrixtonͷEurekaʹ ɹɹAngelͷαʔϏεొͰ͖ͨ 53
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 4. ϚΠΫϩαʔϏετϥΠΞϧୈೋ ࠔͬͨ͜ͱ 1. ୈҰͰ͍ٕͬͯͨज़ελοΫͱͷޓੑ • pom.xmlͷੈ͚ • pom.xmlʢʣ • pom_sb12.xml • pom_sb13.xml – ϙϦάϩοτͷߟ͑ํແࢹ 54
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 4. ϚΠΫϩαʔϏετϥΠΞϧୈೋ ͨ͜͠ͱ 1. ϞχλϦϯάͱΞϥʔτ • αʔόͷϓϩηε͕૿͑ΔͷͰ ࢹ͕ෆՄܽ • ͬͯͳ͔ͬͨΒຊ൪ڥͰো͕ɾɾɾ 55
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 4. ϚΠΫϩαʔϏετϥΠΞϧୈೋ ͨ͜͠ͱ 1. ϞχλϦϯάͱΞϥʔτ • CloudWatch + ΧελϜϝτϦΫεͰऩू • ϦιʔεใʢCPUɺϝϞϦɺσΟεΫʣ • ϓϩηεใʢࢮ׆ʣ • ϩάCloudWatch LogsͱElasticsearchʹू • ϩάࢹCloudWatchͰ࣮ࢪ • ϩάੳΛElasticsearchͰ࣮ࢪ 56
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 57 #5 ϚΠΫϩαʔϏε τϥΠΞϧୈࡾ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 5. ϚΠΫϩαʔϏετϥΠΞϧୈࡾ ͬͨ͜ͱ 1. ߪೖը໘ͷϚΠΫϩαʔϏεԽ • ใαʔϏεɺࡏݿαʔϏεɺ ྉۚαʔϏεͳͲΛՃ։ൃ 2. ٕज़ελοΫ • Spring Bootʢ1.3ܥʣ • Spring CloudʢBrixtonܥʣ • Spring Session + Hazelcastʢηογϣϯڞ༗ʣ 58
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 5. ϚΠΫϩαʔϏετϥΠΞϧୈࡾ ࠔͬͨ͜ͱ 1. վΊͯɺը໘ʹAPI͕Ҿ͖ͮΒΕΔ • ϚΠΫϩαʔϏε : ϦετAPI • ཉ͍͠αʔϏε : ൢചՄೳͳϦετAPI • αʔϏε = Repository? • ͜ͷลΓͰυϝΠϯׂͷॏཁੑʹؾͮ͘ 59
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 5. ϚΠΫϩαʔϏετϥΠΞϧୈࡾ ࠔͬͨ͜ͱ 1. վΊͯɺը໘ʹAPI͕Ҿ͖ͮΒΕΔ • ϑϩϯταʔϏεʢίϯτϩʔϥαʔϏεʣͱ υϝΠϯαʔϏεͷ • ϑϩϯταʔϏε͕ɺඞཁʹԠͯ͡ɺ υϝΠϯαʔϏεΛݺͼग़͢ 60
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 5. ϚΠΫϩαʔϏετϥΠΞϧୈࡾ ࠔͬͨ͜ͱ 1. վΊͯɺը໘ʹAPI͕Ҿ͖ͮΒΕΔ • υϝΠϯαʔϏεͷAPIɺݪଇͱͯ͠ɺ ʮཧը໘Ͱ͑Δʯ͙Β͍ͷ࠶ར༻ੑΛ࣋ͭ 61
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 5. ϚΠΫϩαʔϏετϥΠΞϧୈࡾ ࠔͬͨ͜ͱ 2. طଘॲཧʹ͋ΔڊେͳSQLׂ͕Ͱ͖ͳ͍ • ɺࡏݿɺྉۚͷςʔϒϧͱɺ ͦΕͧͷؔ࿈ςʔϒϧΛ͕ͬͭΓjoinͨ͠SQL 62
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 5. ϚΠΫϩαʔϏετϥΠΞϧୈࡾ ࠔͬͨ͜ͱ 2. طଘॲཧʹ͋ΔڊେͳSQLׂ͕Ͱ͖ͳ͍ • গͳ͘ͱɺɺࡏݿɺྉۚͷɺ υϝΠϯ͙Β͍ʹ͢Δ͕ɺ ؔ࿈ςʔϒϧͷΓ֎͍ͬͨ͠ΜఘΊͨ ɹˠ ͜ͷลΓղܾࡦ͕ݟ͍͑ͯͳ͍ 63
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 64 #6 ࠓޙ औΓΈ͍ͨ͜ͱ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 6. ࠓޙऔΓΈ͍ͨ͜ͱ োୈҰઃܭ 1. ো͕ى͖ΔલఏͰॲཧΛೖΕΔ • Circuit Breakerͱ͍͏֓೦ • ୯Ґ࣌ؒ͋ͨΓͷΤϥʔճ͕ᮢΛ͑ͨΒ ৗʹସॲཧΛߦ͏ʢҰఆ࣌ؒͰ෮ؼʣ • NetflixͷHystrixͰ༰қʹ࣮ݱͰ͖Δ 2. ͱݴ͑ɺো͕ى͖ͨΒͲ͏͢Δͷʁ • ௨͢Δ • ௨৴ΤϥʔΛฦ͢ • ઐ༻ΤϥʔΛฦ͢ • ΩϟογϡΛฦ͢ 65
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 6. ࠓޙऔΓΈ͍ͨ͜ͱ Ωϟογϡ 1. υϝΠϯ͝ͱʹαʔϏεΛ͚Ε υϝΠϯͷಛੑ͝ͱͷΩϟογϡΛ࡞Ͱ͖Δ • ใྉۚසൟʹมΘΒͳ͍͔Β Ωϟογϡ͕ޮ͘ • ࡏݿมಈ͢Δ͔ΒΩϟογϡ͕ޮ͔ͳ͍͠ τϥϯβΫγϣϯݫີʹ͠ͳ͍͚ͯ͘ͳ͍ 66
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 6. ࠓޙऔΓΈ͍ͨ͜ͱ ϙϦάϩοτ 1. GoͷΑ͏ͳϝϞϦϑοτϓϦϯτͷখ͞ͳݴޠΛ͍͍ͨ 2. ෳݴޠͰهࡌ͢Δͱ͖ͷোนϛυϧΣΞ • EurekaΛଞͷݴޠͰ͍͍ͨ 3. ੜ࢈ੑͷӨڹ • Spring Boot + Spring Cloud΄Ͳͷ ੜ࢈ੑΛग़ͤΔΈ߹Θͤগͳ͍ • IDEͷOpen Call HierarchyͰ͍ͬͯͨࣄ͕ Ͱ͖ͳ͘ͳΔ 67
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 6. ࠓޙऔΓΈ͍ͨ͜ͱ ΠϕϯτυϦϒϯ 1. ϦΫΤετΛΠϕϯτͱଊ͑ͯॲཧ͢Δ 2. ঢ়ଶભҠΛΠϕϯτͱଊ͑ͯॲཧ͢Δ 3. όονͳ͠ɺͯ͢ϦΞϧλΠϜͰॲཧ͢Δ 68
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 69 #7 ຊʹ ϚΠΫϩαʔϏε ࠷ద͔ʁ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 7. ຊʹϚΠΫϩαʔϏε࠷ద͔ʁ ຊͱԤถͷจԽͷҧ͍ 1. νʔϜϫʔΫͷҧ͍ • ถ : APIΛܖʹ͢ΔɻAPI͕Ͱ͖ͨΒؼɻ • : ΈΜͳͰ্ख͘ߦ͘Α͏ʹؤுΔɻ ɹɹશମͷͨΊʹAPIΛม͑Δ͜ͱΛ ɹɹ͋·ΓԀΘͳ͍ɻ 70
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 7. ຊʹϚΠΫϩαʔϏε࠷ద͔ʁ ຊͱԤถͷจԽͷҧ͍ 2. DBΞΫηεͷҧ͍ • ถ : JPAɺHibernateɺඞવతʹjoinগͳ͍ • : MyBatisɺDomaɺʢS2Daoʣ ɹɹେͳSQL͕͋ͬͯjoinଟ͍ → ͜ͷ͍ͤͰطଘͷϞϊϦε͔Β ɹɹϚΠΫϩαʔϏεͷҠߦ͕͘͠ͳΔɻ 71
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 7. ຊʹϚΠΫϩαʔϏε࠷ద͔ʁ ຊͱԤถͷจԽͷҧ͍ 3. ϚΠΫϩαʔϏεʮ݁Ռʯ • ࣗͷձࣾɺάϧʔϓɺϓϩδΣΫτʹͱͬͯ దͳΞʔΩςΫνϟʹͳΔΑ͏ ࠷దԽ͢Δඞཁ͕͋Δɻ ڭՊॻͷ·ͶΛͯ͠μϝ 72
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. 73 ·ͱΊ
Copyright © Acroquest Technology Co., Ltd. All rights reserved. Copyright
© Acroquest Technology Co., Ltd. All rights reserved. ·ͱΊ ϚΠΫϩαʔϏε݁Ռ ಉظɺඇಉظɺςετΛؚΊٕͨज़ղΛ໌֬Խ͢Δ Spring Boot + RabbitMQͰ͍·ͷͱ͜Ζͳ͠ ඞਢٕज़ΛѲ͢Δ αʔϏεσΟεΧόϦʢEurekaʣ εέʔϧΠϯɺΞτɺLBɺσϓϩΠ σϓϩΠͷࣗಈԽʢChef / Ansibleʣ ϞχλϦϯάʢCloudWatch / Elasticsearchʣ ׂཻͰΜͩΒʮཧը໘Λ࡞ΕΔAPIʯ͕Ұͭͷ҆ ࣗͨͪͷ৫ʹ߹Θͤͨ࠷దԽ͕ඞਢ 74
Copyright © Acroquest Technology Co., Ltd. All rights reserved. 75
Enjoy your own microservices architecture!