SlideShare a Scribd company logo
‹#›© 2016 Pivotal Software, Inc. All rights reserved. ‹#›© 2016 Pivotal Software, Inc. All rights reserved.
Spring Cloud Services
Toshiaki Maki (@making)
PCF Meetup
2016-06-29
© 2016 Pivotal Software, Inc. All rights reserved.
Who am I ?
• Toshiaki Maki (@making)
• Sr. Solutions Architect
• Spring Framework enthusiast
Perfect
Java EE
(Coming Soon)
bit.ly/spring-book
‹#›© 2016 Pivotal Software, Inc. All rights reserved.
Spring Cloud
© 2016 Pivotal Software, Inc. All rights reserved.
Spring Cloud
• Omakase Microservices
© 2016 Pivotal Software, Inc. All rights reserved.
• Service Discovery
• API Gateway
• Client-side Load Balancing
• Circuit Breakers
• Distributed Configuration
• Distributed Tracing
Spring Cloud Provides
Hystrix
Ribbon
Zuul
Eureka
Zipkin
© 2016 Pivotal Software, Inc. All rights reserved.
• Service Registry

Registry 

• 

" (host )" 

" " ( )
• Registry 

• Service Discovery
• Eureka (Netflix)
• Consul (HashiCorp)
• Zookeeper
Service Discovery
© 2016 Pivotal Software, Inc. All rights reserved.
• Service Registry 





• Netflix Ribbon
Client-side Load Balancing
© 2016 Pivotal Software, Inc. All rights reserved.
• 



( )
• 

(Open) 



(Half-Open) 

(Closed)
• Netflix Hystrix
•
Circuit Breaker
© 2016 Pivotal Software, Inc. All rights reserved.
• 

REST API 

• 

• Git/Subversion/

Distributed Configuration
‹#›© 2016 Pivotal Software, Inc. All rights reserved.
Spring Cloud
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
• Spring Boot
• Spring Cloud
• @EnableXxxServer
•
© 2016 Pivotal Software, Inc. All rights reserved.
Implement Config Server
© 2016 Pivotal Software, Inc. All rights reserved.
Add dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
© 2016 Pivotal Software, Inc. All rights reserved.
Create Config Server
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Create Config Server
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Configure Config Server
spring.cloud.config.server.git.uri=https://github.com/
making/metflix-config.git
© 2016 Pivotal Software, Inc. All rights reserved.
Configure Config Client
© 2016 Pivotal Software, Inc. All rights reserved.
Add dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
© 2016 Pivotal Software, Inc. All rights reserved.
Configure Config Client
spring.cloud.config.uri=http://localhost:8888
spring.application.name=membership
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
Implement Service Registry
© 2016 Pivotal Software, Inc. All rights reserved.
Add dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
© 2016 Pivotal Software, Inc. All rights reserved.
Create Eureka Server
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class,
args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Create Eureka Server
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class,
args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
Configure Discovery Clients
© 2016 Pivotal Software, Inc. All rights reserved.
Add dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
© 2016 Pivotal Software, Inc. All rights reserved.
Create Eureka Client
@SpringBootApplication
@EnableDiscoveryClient
public class RecommendationsApplication {
public static void main(String[] args) {
SpringApplication.run(RecommendationsApplication.class,
args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Create Eureka Client
@SpringBootApplication
@EnableDiscoveryClient
public class RecommendationsApplication {
public static void main(String[] args) {
SpringApplication.run(RecommendationsApplication.class,
args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
Introduce Circuit Breaker
© 2016 Pivotal Software, Inc. All rights reserved.
Add dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
© 2016 Pivotal Software, Inc. All rights reserved.
Use Hystrix
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
public class RecommendationsApplication {
public static void main(String[] args) {
SpringApplication.run(RecommendationsApplication.class,
args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Use Hystrix
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker
public class RecommendationsApplication {
public static void main(String[] args) {
SpringApplication.run(RecommendationsApplication.class,
args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Configure Hystrix Command
@Component
public class RecommendationsService {
@HystrixCommand(fallbackMethod =
"recommendationFallback")
List<Movie> findRecommendationsForUser(String user) {
// some recommendation logic
}
List<Movie> recommendationFallback(String user) {
return top5Movies;
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Configure Hystrix Command
@Component
public class RecommendationsService {
@HystrixCommand(fallbackMethod =
"recommendationFallback")
List<Movie> findRecommendationsForUser(String user) {
// some recommendation logic
}
List<Movie> recommendationFallback(String user) {
return top5Movies;
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Configure Hystrix Command
@Component
public class RecommendationsService {
@HystrixCommand(fallbackMethod =
"recommendationFallback")
List<Movie> findRecommendationsForUser(String user) {
// some recommendation logic
}
List<Movie> recommendationFallback(String user) {
return top5Movies;
}
}
👈
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Configure Hystrix Command
@Component
public class RecommendationsService {
@HystrixCommand(fallbackMethod =
"recommendationFallback")
List<Movie> findRecommendationsForUser(String user) {
// some recommendation logic
}
List<Movie> recommendationFallback(String user) {
return top5Movies;
}
}
👈
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Implement Circuit Breaker Dashboard
© 2016 Pivotal Software, Inc. All rights reserved.
Add dependency
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
© 2016 Pivotal Software, Inc. All rights reserved.
Create Dashboard Server
@SpringBootApplication
@EnableHystrixDashboard
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class,
args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
Create Dashboard Server
@SpringBootApplication
@EnableHystrixDashboard
public class HystrixDashboardApplication {
public static void main(String[] args) {
SpringApplication.run(HystrixDashboardApplication.class,
args);
}
}
👈
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
Hystrix Dashboard
• 1 (=1 )
• Turbine
• Server-Sent Event pull PaaS
1URL
‹#›© 2016 Pivotal Software, Inc. All rights reserved.
Spring Cloud Services
© 2016 Pivotal Software, Inc. All rights reserved.
"Spring Cloud as a Service"
© 2016 Pivotal Software, Inc. All rights reserved.
• Spring Boot
• Spring Cloud
• @EnableXxxServer
•
•
•
© 2016 Pivotal Software, Inc. All rights reserved.
• Spring Boot
• Spring Cloud
• @EnableXxxServer
•
•
•
• cf create-service
© 2016 Pivotal Software, Inc. All rights reserved.
• Spring Boot
• Spring Cloud
•
•
© 2016 Pivotal Software, Inc. All rights reserved.
• Spring Boot
• Spring Cloud
•
•
• Spring Boot
• Spring Cloud Services
•
• cf bind-service
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
🔒 🔒 🔒
© 2016 Pivotal Software, Inc. All rights reserved.
🔒 🔒 🔒
OAuth2
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
Create services
cf create-service p-config-server standard config-server 
-c '{"git":{"uri":"https://github.com/making/metflix-config"}}'
cf create-service p-service-registry standard eureka-server
cf create-service p-circuit-breaker-dashboard standard 
hystrix-dashboard
© 2016 Pivotal Software, Inc. All rights reserved.
Bind Services
cf bind-service membership config-server
cf bind-service recommendations config-server
cf bind-service ui config-server
cf bind-service membership eureka-server
cf bind-service recommendations eureka-server
cf bind-service ui eureka-server
cf bind-service recommendations hystrix-dashboard
cf bind-service ui hystrix-dashboard
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
© 2016 Pivotal Software, Inc. All rights reserved.
RabbitMQ push
!!
© 2016 Pivotal Software, Inc. All rights reserved.
• Spring Cloud r
• Spring Cloud Service = "Spring Cloud" as a service
• @EnableXxxServer --> cf create-service + OAuth2
© 2016 Pivotal Software, Inc. All rights reserved.
Links
• http://www.slideshare.net/SpringCentral/cloud-native-java-
with-spring-cloud-services
• https://github.com/Pivotal-Japan/cloud-native-workshop

More Related Content

PDF
Spring ❤️ Kotlin #jjug
PDF
Why PCF is the best platform for Spring Boot
PDF
Managing your Docker image continuously with Concourse CI
PDF
Spring Boot 1.3 News #渋谷Java
PDF
Concourse x Spinnaker #concourse_tokyo
PDF
Team Support in Concourse CI 2.0 #concourse_tokyo
PDF
BOSH / CF Deployment in modern ways #cf_tokyo
PDF
From Zero to Hero with REST and OAuth2 #jjug
Spring ❤️ Kotlin #jjug
Why PCF is the best platform for Spring Boot
Managing your Docker image continuously with Concourse CI
Spring Boot 1.3 News #渋谷Java
Concourse x Spinnaker #concourse_tokyo
Team Support in Concourse CI 2.0 #concourse_tokyo
BOSH / CF Deployment in modern ways #cf_tokyo
From Zero to Hero with REST and OAuth2 #jjug

What's hot (20)

PDF
Introduction to Spring WebFlux #jsug #sf_a1
PDF
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
PDF
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
PDF
Implement Service Broker with Spring Boot #cf_tokyo
PDF
クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)
PDF
手把手教你如何串接 Log 到各種網路服務
PDF
Cloud Foundy Java Client V 2.0 #cf_tokyo
PDF
Using JHipster 4 for generating Angular/Spring Boot apps
PDF
Immutable infrastructure:觀念與實作 (建議)
PDF
Spring5 New Features - Nov, 2017
ODP
Xke spring boot
PDF
SpringOne Platform recap 정윤진
PDF
Using JHipster for generating Angular/Spring Boot apps
PPTX
How to customize Spring Boot?
PDF
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
ODP
Migrating to Git: Rethinking the Commit
PDF
2017年のLINEのマイクロサービスを支えるSpring
PDF
Using React with Grails 3
PDF
Java REST API Framework Comparison - UberConf 2021
PPTX
Spring Boot and REST API
Introduction to Spring WebFlux #jsug #sf_a1
From Spring Boot 2.2 to Spring Boot 2.3 #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
Implement Service Broker with Spring Boot #cf_tokyo
クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)
手把手教你如何串接 Log 到各種網路服務
Cloud Foundy Java Client V 2.0 #cf_tokyo
Using JHipster 4 for generating Angular/Spring Boot apps
Immutable infrastructure:觀念與實作 (建議)
Spring5 New Features - Nov, 2017
Xke spring boot
SpringOne Platform recap 정윤진
Using JHipster for generating Angular/Spring Boot apps
How to customize Spring Boot?
Full Stack Reactive with React and Spring WebFlux - SpringOne 2018
Migrating to Git: Rethinking the Commit
2017年のLINEのマイクロサービスを支えるSpring
Using React with Grails 3
Java REST API Framework Comparison - UberConf 2021
Spring Boot and REST API
Ad

Similar to Spring Cloud Servicesの紹介 #pcf_tokyo (20)

PDF
Microservices with Spring and Cloud Foundry
PDF
Microservices with Spring and Cloud Foundry
PDF
Pivotal microservices spring_pcf_skillsmatter.pptx
PPTX
Intro to Spring Boot and Spring Cloud OSS - Twin Cities Cloud Foundry Meetup
PPTX
Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup
PDF
Cloud Native Microservices with Spring Cloud
PDF
Cloud Native Java with Spring Cloud Services
PDF
Cloud Native Microservices with Spring Cloud
PPTX
TDC2016SP - Construindo Microserviços usando Spring Cloud
PDF
Developing Resilient Cloud Native Apps with Spring Cloud
PDF
Resilient Microservices with Spring Cloud
PDF
점진적인 레거시 웹 애플리케이션 개선 과정
PPTX
Microservices with kubernetes @190316
PDF
SpringBoot and Spring Cloud Service for MSA
PDF
Building Distributed Systems with Netflix OSS and Spring Cloud
PDF
Simplify Cloud Applications using Spring Cloud
PDF
Arquitecturas de microservicios - Medianet Software
PPTX
TDC 2016 - Arquitetura Java - Spring Cloud
PPTX
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
PPTX
Spring on PAS - Fabio Marinelli
Microservices with Spring and Cloud Foundry
Microservices with Spring and Cloud Foundry
Pivotal microservices spring_pcf_skillsmatter.pptx
Intro to Spring Boot and Spring Cloud OSS - Twin Cities Cloud Foundry Meetup
Introduction to Spring Cloud OSS - Denver Cloud Foundry Meetup
Cloud Native Microservices with Spring Cloud
Cloud Native Java with Spring Cloud Services
Cloud Native Microservices with Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring Cloud
Developing Resilient Cloud Native Apps with Spring Cloud
Resilient Microservices with Spring Cloud
점진적인 레거시 웹 애플리케이션 개선 과정
Microservices with kubernetes @190316
SpringBoot and Spring Cloud Service for MSA
Building Distributed Systems with Netflix OSS and Spring Cloud
Simplify Cloud Applications using Spring Cloud
Arquitecturas de microservicios - Medianet Software
TDC 2016 - Arquitetura Java - Spring Cloud
Implementing Micro Services Tasks (service discovery, load balancing etc.) - ...
Spring on PAS - Fabio Marinelli
Ad

More from Toshiaki Maki (18)

PDF
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
PDF
決済システムの内製化への旅 - SpringとPCFで作るクラウドネイティブなシステム開発 #jsug #sf_h1
PDF
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
PDF
Spring Boot Actuator 2.0 & Micrometer
PDF
Open Service Broker APIとKubernetes Service Catalog #k8sjp
PDF
Spring Cloud Function & Project riff #jsug
PDF
Zipkin Components #zipkin_jp
PPTX
マイクロサービスに必要な技術要素はすべてSpring Cloudにある #DO07
PDF
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
PDF
Event Driven Microservices with Spring Cloud Stream #jjug_ccc #ccc_ab3
PDF
Data Microservices with Spring Cloud Stream, Task, and Data Flow #jsug #spri...
PDF
Short Lived Tasks in Cloud Foundry #cfdtokyo
PDF
今すぐ始めるCloud Foundry #hackt #hackt_k
PDF
Consumer Driven Contractsで REST API/マイクロサービスをテスト #m3tech
PDF
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
PDF
Concourse CI Meetup Demo
PDF
Install Concourse CI with BOSH
PDF
Introduction to Concourse CI #渋谷Java
Serverless with Spring Cloud Function, Knative and riff #SpringOneTour #s1t
決済システムの内製化への旅 - SpringとPCFで作るクラウドネイティブなシステム開発 #jsug #sf_h1
Spring Boot Actuator 2.0 & Micrometer #jjug_ccc #ccc_a1
Spring Boot Actuator 2.0 & Micrometer
Open Service Broker APIとKubernetes Service Catalog #k8sjp
Spring Cloud Function & Project riff #jsug
Zipkin Components #zipkin_jp
マイクロサービスに必要な技術要素はすべてSpring Cloudにある #DO07
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Event Driven Microservices with Spring Cloud Stream #jjug_ccc #ccc_ab3
Data Microservices with Spring Cloud Stream, Task, and Data Flow #jsug #spri...
Short Lived Tasks in Cloud Foundry #cfdtokyo
今すぐ始めるCloud Foundry #hackt #hackt_k
Consumer Driven Contractsで REST API/マイクロサービスをテスト #m3tech
#jjug_ccc #ccc_gh5 What's new in Spring Framework 4.3 / Boot 1.4 + Pivotal's ...
Concourse CI Meetup Demo
Install Concourse CI with BOSH
Introduction to Concourse CI #渋谷Java

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PDF
cuic standard and advanced reporting.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Approach and Philosophy of On baking technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
KodekX | Application Modernization Development
cuic standard and advanced reporting.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Electronic commerce courselecture one. Pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
“AI and Expert System Decision Support & Business Intelligence Systems”
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Empathic Computing: Creating Shared Understanding
Approach and Philosophy of On baking technology
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
The AUB Centre for AI in Media Proposal.docx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Spring Cloud Servicesの紹介 #pcf_tokyo

  • 1. ‹#›© 2016 Pivotal Software, Inc. All rights reserved. ‹#›© 2016 Pivotal Software, Inc. All rights reserved. Spring Cloud Services Toshiaki Maki (@making) PCF Meetup 2016-06-29
  • 2. © 2016 Pivotal Software, Inc. All rights reserved. Who am I ? • Toshiaki Maki (@making) • Sr. Solutions Architect • Spring Framework enthusiast Perfect Java EE (Coming Soon) bit.ly/spring-book
  • 3. ‹#›© 2016 Pivotal Software, Inc. All rights reserved. Spring Cloud
  • 4. © 2016 Pivotal Software, Inc. All rights reserved. Spring Cloud • Omakase Microservices
  • 5. © 2016 Pivotal Software, Inc. All rights reserved. • Service Discovery • API Gateway • Client-side Load Balancing • Circuit Breakers • Distributed Configuration • Distributed Tracing Spring Cloud Provides Hystrix Ribbon Zuul Eureka Zipkin
  • 6. © 2016 Pivotal Software, Inc. All rights reserved. • Service Registry
 Registry 
 • 
 " (host )" 
 " " ( ) • Registry 
 • Service Discovery • Eureka (Netflix) • Consul (HashiCorp) • Zookeeper Service Discovery
  • 7. © 2016 Pivotal Software, Inc. All rights reserved. • Service Registry 
 
 
 • Netflix Ribbon Client-side Load Balancing
  • 8. © 2016 Pivotal Software, Inc. All rights reserved. • 
 
 ( ) • 
 (Open) 
 
 (Half-Open) 
 (Closed) • Netflix Hystrix • Circuit Breaker
  • 9. © 2016 Pivotal Software, Inc. All rights reserved. • 
 REST API 
 • 
 • Git/Subversion/
 Distributed Configuration
  • 10. ‹#›© 2016 Pivotal Software, Inc. All rights reserved. Spring Cloud
  • 11. © 2016 Pivotal Software, Inc. All rights reserved.
  • 12. © 2016 Pivotal Software, Inc. All rights reserved.
  • 13. © 2016 Pivotal Software, Inc. All rights reserved. • Spring Boot • Spring Cloud • @EnableXxxServer •
  • 14. © 2016 Pivotal Software, Inc. All rights reserved. Implement Config Server
  • 15. © 2016 Pivotal Software, Inc. All rights reserved. Add dependency <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency>
  • 16. © 2016 Pivotal Software, Inc. All rights reserved. Create Config Server @SpringBootApplication @EnableConfigServer public class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } } 👈
  • 17. © 2016 Pivotal Software, Inc. All rights reserved. Create Config Server @SpringBootApplication @EnableConfigServer public class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } } 👈
  • 18. © 2016 Pivotal Software, Inc. All rights reserved. Configure Config Server spring.cloud.config.server.git.uri=https://github.com/ making/metflix-config.git
  • 19. © 2016 Pivotal Software, Inc. All rights reserved. Configure Config Client
  • 20. © 2016 Pivotal Software, Inc. All rights reserved. Add dependency <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency>
  • 21. © 2016 Pivotal Software, Inc. All rights reserved. Configure Config Client spring.cloud.config.uri=http://localhost:8888 spring.application.name=membership
  • 22. © 2016 Pivotal Software, Inc. All rights reserved.
  • 23. © 2016 Pivotal Software, Inc. All rights reserved. Implement Service Registry
  • 24. © 2016 Pivotal Software, Inc. All rights reserved. Add dependency <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency>
  • 25. © 2016 Pivotal Software, Inc. All rights reserved. Create Eureka Server @SpringBootApplication @EnableEurekaServer public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } } 👈
  • 26. © 2016 Pivotal Software, Inc. All rights reserved. Create Eureka Server @SpringBootApplication @EnableEurekaServer public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } } 👈
  • 27. © 2016 Pivotal Software, Inc. All rights reserved.
  • 28. © 2016 Pivotal Software, Inc. All rights reserved. Configure Discovery Clients
  • 29. © 2016 Pivotal Software, Inc. All rights reserved. Add dependency <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency>
  • 30. © 2016 Pivotal Software, Inc. All rights reserved. Create Eureka Client @SpringBootApplication @EnableDiscoveryClient public class RecommendationsApplication { public static void main(String[] args) { SpringApplication.run(RecommendationsApplication.class, args); } } 👈
  • 31. © 2016 Pivotal Software, Inc. All rights reserved. Create Eureka Client @SpringBootApplication @EnableDiscoveryClient public class RecommendationsApplication { public static void main(String[] args) { SpringApplication.run(RecommendationsApplication.class, args); } } 👈
  • 32. © 2016 Pivotal Software, Inc. All rights reserved.
  • 33. © 2016 Pivotal Software, Inc. All rights reserved. Introduce Circuit Breaker
  • 34. © 2016 Pivotal Software, Inc. All rights reserved. Add dependency <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency>
  • 35. © 2016 Pivotal Software, Inc. All rights reserved. Use Hystrix @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker public class RecommendationsApplication { public static void main(String[] args) { SpringApplication.run(RecommendationsApplication.class, args); } } 👈
  • 36. © 2016 Pivotal Software, Inc. All rights reserved. Use Hystrix @SpringBootApplication @EnableDiscoveryClient @EnableCircuitBreaker public class RecommendationsApplication { public static void main(String[] args) { SpringApplication.run(RecommendationsApplication.class, args); } } 👈
  • 37. © 2016 Pivotal Software, Inc. All rights reserved. Configure Hystrix Command @Component public class RecommendationsService { @HystrixCommand(fallbackMethod = "recommendationFallback") List<Movie> findRecommendationsForUser(String user) { // some recommendation logic } List<Movie> recommendationFallback(String user) { return top5Movies; } } 👈
  • 38. © 2016 Pivotal Software, Inc. All rights reserved. Configure Hystrix Command @Component public class RecommendationsService { @HystrixCommand(fallbackMethod = "recommendationFallback") List<Movie> findRecommendationsForUser(String user) { // some recommendation logic } List<Movie> recommendationFallback(String user) { return top5Movies; } } 👈
  • 39. © 2016 Pivotal Software, Inc. All rights reserved. Configure Hystrix Command @Component public class RecommendationsService { @HystrixCommand(fallbackMethod = "recommendationFallback") List<Movie> findRecommendationsForUser(String user) { // some recommendation logic } List<Movie> recommendationFallback(String user) { return top5Movies; } } 👈 👈
  • 40. © 2016 Pivotal Software, Inc. All rights reserved. Configure Hystrix Command @Component public class RecommendationsService { @HystrixCommand(fallbackMethod = "recommendationFallback") List<Movie> findRecommendationsForUser(String user) { // some recommendation logic } List<Movie> recommendationFallback(String user) { return top5Movies; } } 👈 👈
  • 41. © 2016 Pivotal Software, Inc. All rights reserved. Implement Circuit Breaker Dashboard
  • 42. © 2016 Pivotal Software, Inc. All rights reserved. Add dependency <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId> </dependency>
  • 43. © 2016 Pivotal Software, Inc. All rights reserved. Create Dashboard Server @SpringBootApplication @EnableHystrixDashboard public class HystrixDashboardApplication { public static void main(String[] args) { SpringApplication.run(HystrixDashboardApplication.class, args); } } 👈
  • 44. © 2016 Pivotal Software, Inc. All rights reserved. Create Dashboard Server @SpringBootApplication @EnableHystrixDashboard public class HystrixDashboardApplication { public static void main(String[] args) { SpringApplication.run(HystrixDashboardApplication.class, args); } } 👈
  • 45. © 2016 Pivotal Software, Inc. All rights reserved.
  • 46. © 2016 Pivotal Software, Inc. All rights reserved.
  • 47. © 2016 Pivotal Software, Inc. All rights reserved. Hystrix Dashboard • 1 (=1 ) • Turbine • Server-Sent Event pull PaaS 1URL
  • 48. ‹#›© 2016 Pivotal Software, Inc. All rights reserved. Spring Cloud Services
  • 49. © 2016 Pivotal Software, Inc. All rights reserved. "Spring Cloud as a Service"
  • 50. © 2016 Pivotal Software, Inc. All rights reserved. • Spring Boot • Spring Cloud • @EnableXxxServer • • •
  • 51. © 2016 Pivotal Software, Inc. All rights reserved. • Spring Boot • Spring Cloud • @EnableXxxServer • • • • cf create-service
  • 52. © 2016 Pivotal Software, Inc. All rights reserved. • Spring Boot • Spring Cloud • •
  • 53. © 2016 Pivotal Software, Inc. All rights reserved. • Spring Boot • Spring Cloud • • • Spring Boot • Spring Cloud Services • • cf bind-service
  • 54. © 2016 Pivotal Software, Inc. All rights reserved.
  • 55. © 2016 Pivotal Software, Inc. All rights reserved. 🔒 🔒 🔒
  • 56. © 2016 Pivotal Software, Inc. All rights reserved. 🔒 🔒 🔒 OAuth2
  • 57. © 2016 Pivotal Software, Inc. All rights reserved.
  • 58. © 2016 Pivotal Software, Inc. All rights reserved.
  • 59. © 2016 Pivotal Software, Inc. All rights reserved.
  • 60. © 2016 Pivotal Software, Inc. All rights reserved. Create services cf create-service p-config-server standard config-server -c '{"git":{"uri":"https://github.com/making/metflix-config"}}' cf create-service p-service-registry standard eureka-server cf create-service p-circuit-breaker-dashboard standard hystrix-dashboard
  • 61. © 2016 Pivotal Software, Inc. All rights reserved. Bind Services cf bind-service membership config-server cf bind-service recommendations config-server cf bind-service ui config-server cf bind-service membership eureka-server cf bind-service recommendations eureka-server cf bind-service ui eureka-server cf bind-service recommendations hystrix-dashboard cf bind-service ui hystrix-dashboard
  • 62. © 2016 Pivotal Software, Inc. All rights reserved.
  • 63. © 2016 Pivotal Software, Inc. All rights reserved.
  • 64. © 2016 Pivotal Software, Inc. All rights reserved.
  • 65. © 2016 Pivotal Software, Inc. All rights reserved. RabbitMQ push !!
  • 66. © 2016 Pivotal Software, Inc. All rights reserved. • Spring Cloud r • Spring Cloud Service = "Spring Cloud" as a service • @EnableXxxServer --> cf create-service + OAuth2
  • 67. © 2016 Pivotal Software, Inc. All rights reserved. Links • http://www.slideshare.net/SpringCentral/cloud-native-java- with-spring-cloud-services • https://github.com/Pivotal-Japan/cloud-native-workshop