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
7k
実践して分かった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.1k
26 Java Years
shintanimoto
0
43
Let’s Have Fun with Reactive Programming, Using Reactor and WebFlux
shintanimoto
0
220
Monitoring and Visualizing Your (Micro)services
shintanimoto
0
320
現代に求められるJavaコミュニティとは / What should be the Java Community of Today?
shintanimoto
0
840
人生がときめく「学び」の魔法 / The Life-Changing Magic of Studying
shintanimoto
6
1.5k
業務で使いたいWebFluxによるReactiveプログラミング / Introduction to Reactive Programming using Spring WebFlux
shintanimoto
9
8.8k
from old Java to modern Java (2017) #jjug
shintanimoto
4
1.5k
Spring Cloud Sleuth + Zipkin with Elasticsearch #zipkin_jp
shintanimoto
1
1.2k
Other Decks in Programming
See All in Programming
KSPの導入・移行を前向きに検討しよう!
shxun6934
PRO
0
120
dRuby 入門者によるあなたの身近にあるdRuby 入門
makicamel
4
350
僕が思い描くTypeScriptの未来を勝手に先取りする
yukukotani
9
2.3k
Our Websites Need a Lifestyle Change, Not a Diet
ryantownsend
0
120
Mastering AsyncSequence - 使う・作る・他のデザインパターン(クロージャ、Delegate など)から移行する
treastrain
4
1.5k
React + TextAliveでカッコいいLyric Applicatioinを作ろう!!
tosuri13
0
390
Go Code Generation at newmo / 2024-08-27 #newmo_layerx_go
genkey6
0
550
Some more adventure of Happy Eyeballs
coe401_
2
170
Why Prism?
kddnewton
4
1.7k
rbs-inlineを導入してYARDからRBSに移行する
euglena1215
1
240
私のEbitengineの第一歩
qt_luigi
0
440
LR で JSON パーサーを作る / Coding LR JSON Parser
junk0612
2
180
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
786
250k
A Modern Web Designer's Workflow
chriscoyier
691
190k
Creatively Recalculating Your Daily Design Routine
revolveconf
215
12k
YesSQL, Process and Tooling at Scale
rocio
167
14k
Building Better People: How to give real-time feedback that sticks.
wjessup
359
18k
How to Ace a Technical Interview
jacobian
275
23k
We Have a Design System, Now What?
morganepeng
48
7.1k
The World Runs on Bad Software
bkeepers
PRO
64
11k
Infographics Made Easy
chrislema
239
18k
Become a Pro
speakerdeck
PRO
22
4.9k
Building Adaptive Systems
keathley
36
2.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
43
2k
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!