SlideShare a Scribd company logo
1 of 61
Download to read offline
Simplify Cloud Applications using 
Spring Cloud 
Ramnivas Laddad and Scott Frederick 
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Agenda 
• Spring Cloud Basics 
• Application Config Options 
• Java config 
• XML config 
• Extensibility mechanism 
• Cloud Platforms 
• Cloud Services 
• Frameworks 
• Spring Boot Integration 
2
Cloud Apps Awareness 
3
Cloud Apps Awareness 
3 
Application
Container 
Cloud Apps Awareness 
3 
Application
Container 
Cloud Apps Awareness 
3 
Application 
App Instance 
Information
Container 
Cloud Apps Awareness 
3 
Application 
Service 
App Instance 
Information
Container 
Cloud Apps Awareness 
3 
Application 
Service 
Services 
Information 
App Instance 
Information
Cloud Apps Awareness: 
Cloud Foundry Instance Information 
{ 
"limits": { 
"mem" : 512, "disk" : 1024, "fds" : 16384 
}, 
"application_version":"5e6fe3f7-6900-4af8-8376-bf3223ce886b", 
"application_name":"hello-spring-cloud", 
"application_uris":["myapp.cfapps.io"], 
"version":"5e6fe3f7-6900-4af8-8376-bf3223ce886b", 
"name":"hello-spring-cloud", 
"space_name":"development", 
"space_id":"5f629937-1821-4f48-9eb4-8c67c70c0df0", 
"instance_id":"b84fa4cd1c75431486dec1609828ae36", 
"instance_index":0, 
"host":"0.0.0.0", 
"port":63202, 
"started_at_timestamp":1401394307, 
"state_timestamp":1401394307 
} 
4 
VCAP_APPLICATION env variable
Cloud Apps Awareness: Cloud Foundry Services 
{ 
"elephantsql": [ 
{ 
"name" : "inventory-db", 
"label" : "elephantsql", 
"tags" : ["relational","Data Store","postgresql"], 
"plan" : "turtle", 
"credentials" : { 
"uri" : "postgres://user:pass@babar.elephantsql.com:5432/db", 
"max_conns" : "5" 
} 
} 
], 
"rediscloud": [ 
{ 
"name" : "rediscloud-service", 
"label" : "rediscloud", 
"tags" : ["key-value","redis","Data Store"], 
"plan" : "25mb", 
"credentials" : { 
"hostname" : "pub-redis.garantiadata.com", 
"port" : "11853", 
"password" : "pass" 
} 
} 
] 
} 
5 
VCAP_SERVICES env variable
Cloud Apps Awareness: 
Heroku Instance Information 
• Individual env variables 
! 
PORT 
12345 
! 
DYNO 
web.1 
! 
6
Cloud Apps Awareness: Heroku Services 
• One environment variable per service 
! 
HEROKU_POSTGRESQL_PURPLE_URL 
postgres://user:pass@host.amazonaws.com:5432/db 
! 
REDISCLOUD_URL 
redis://rediscloud:pass@host.garantiadata.com:19038 
REDISTOGO_URL 
redis://redistogo:pass@host.redistogo.com:9139 
7
Spring Cloud Goals 
• Abstraction over cloud services and application environment 
• Implementation for multiple cloud platforms 
• Cloud Foundry 
• Heroku 
• Local testing simulating a cloud-like environment 
• Extensibility without modifying the core code 
• Cloud Connector 
• Service Creator 
8
Using Java Config 
9
Scanning for services 
!! 
@Configuration 
@CloudScan 
public class CloudConfig { 
! 
} 
10
Scanning for services 
!! 
@Configuration 
@CloudScan 
public class CloudConfig { 
! 
} 
10
Taking over control 
@Configuration 
public class CloudConfig extends AbstractCloudConfig { 
@Bean 
public DataSource dataSource() { 
return connectionFactory().dataSource(); 
} 
! 
@Bean 
public MongoDbFactory mongoDb() { 
return connectionFactory().mongoDbFactory(); 
} 
} 
11
Taking over control: Working with specific services 
@Configuration 
public class CloudConfig extends AbstractCloudConfig { 
@Bean 
public DataSource inventoryDataSource() { 
return connectionFactory().dataSource("inventory-service"); 
} 
! 
@Bean 
public DataSource customerDataSource() { 
return connectionFactory().dataSource("customers-service"); 
} 
} 
12
Taking over control: Configuring Services 
@Configuration 
public class CloudConfig extends AbstractCloudConfig { 
@Bean 
public DataSource inventoryDataSource() { 
PoolConfig poolConfig = new PoolConfig(20, 200); 
ConnectionConfig connectionConfig = 
new ConnectionConfig("characterEncoding=UTF-8"); 
DataSourceConfig serviceConfig = 
new DataSourceConfig(poolConfig, connectionConfig); 
return connectionFactory().dataSource( 
"inventory-service", serviceConfig); 
} 
} 
13
Acquiring generic services 
@Configuration 
public class CloudConfig extends AbstractCloudConfig { 
@Bean 
public Search search() { 
return connectionFactory().service( 
"search-service", Search.class); 
} 
} 
14
Demo 
Spring Cloud on Cloud Foundry 
15
Deploy to Cloud Foundry 
$ gradle assemble 
$ cf create-service cleardb spark cities-db 
$ cf push 
16 
--- 
applications: 
- name: cities 
host: cities-s12gx 
path: build/libs/spring-boot-cities.jar 
services: 
- cities-db 
env: 
SPRING_PROFILES_ACTIVE: cloud 
http://cities-s12gx.cfapps.io/
Demo 
Spring Cloud on Heroku 
17
Deploy to Heroku 
$ heroku create cities-s12gx --stack cedar --buildpack http:// 
github.com/heroku/heroku-buildpack-java.git 
$ heroku config:set SPRING_CLOUD_APP_NAME=spring-boot-cities 
$ heroku config:set SPRING_PROFILES_ACTIVE=cloud 
$ heroku addons:add heroku-postgresql:hobby-dev 
$ git push heroku master 
18 
http://cities-s12gx.herokuapp.com/
Using XML Config 
19
Scanning for services 
20 
<cloud:service-scan/>
Taking over control 
21 
<cloud:data-source/> 
! 
<cloud:mongo-db-factory/> 
! 
...
Taking over control: Specifying services 
22 
<cloud:data-source 
service-name="inventory-service"/> 
! 
<cloud:data-source 
service-name="customers-service"/>
Taking over control: Configuring Services 
23 
<cloud:data-source service-name="inventory-service"> 
<cloud:pool pool-size="20" max-wait-time="200"/> 
<cloud:connection properties="characterEncoding=UTF-8"/> 
</cloud:data-source>
Acquiring generic services 
24 
<cloud:service service-name="search-service"/>
Acquiring generic services 
24 
<cloud:service service-name="search-service"/> 
<cloud:service service-name="search-service" 
connector-type="com.example.Search"/>
Services Supported 
• Cloud Foundry, Heroku, and Local connectors with Spring 
• MySQL, Postgres, Oracle 
• Redis 
• MongoDB 
• AMQP / RabbitMQ 
• SMTP 
• Pivotal CF connectors with Spring 
• Pivotal HD 
25
Demo 
Spring Cloud with Hadoop 
26
Explicit Cloud Config 
27 
@org.springframework.context.annotation.Configuration 
public class CloudConfig extends AbstractCloudConfig { 
@Bean 
public ConnectionFactory rabbitConnectionFactory() { 
return connectionFactory().rabbitConnectionFactory(); 
} 
@Bean 
public DataSource hawqDataSource() { 
return connectionFactory().dataSource("phd-service/hawq"); 
} ! 
@Bean 
public DataSource gemfirexdDataSource() { 
return connectionFactory().dataSource("phd-service/gemfirexd"); 
} 
@Bean 
public Configuration hadoopConfiguration() { 
return connectionFactory().service(Configuration.class); 
} 
}
Consuming Service Beans: Explicit Config 
28 
@Autowired @Qualifier("hawqDataSource") 
DataSource hawqDataSource; 
@Autowired @Qualifier(“gemfirexdDataSource") 
DataSource gemfirexdDataSource; 
! 
@Autowired ConnectionFactory rabbitConnectionFactory; 
! 
@Autowired Configuration hadoopConfiguration; 
!!
Cloud Config with Scanning 
29 
@Configuration 
@CloudScan 
public class CloudConfig { 
}
Consuming Service Beans: Explicit Config 
30 
@Autowired @Qualifier("phd-service/hawq") 
DataSource hawqDataSource; 
@Autowired @Qualifier("phd-service/gemfirexd") 
DataSource gemfirexdDataSource; 
! 
@Autowired ConnectionFactory rabbitConnectionFactory; 
! 
@Autowired Configuration hadoopConfiguration;
Spring Cloud Extensibility 
31
Axes of Extensibility 
32
Axes of Extensibility 
32 
Cloud Platform
Axes of Extensibility 
32 
Cloud Platform 
Cloud Services
Axes of Extensibility 
32 
Cloud Platform 
Cloud Services 
Framework Support
Service Connector 
Extensibility Overview 
ServiceInfo 
33 
CloudConnector ServiceConnectorCreator 
SSerevrivciec eC Cononnencetcotror
Cloud Platform Extensibility 
34 
public interface CloudConnector { 
! 
boolean isInMatchingCloud(); 
ApplicationInstanceInfo getApplicationInstanceInfo(); 
! 
List<ServiceInfo> getServiceInfos(); 
}
Registering Cloud Connector 
! 
• Add a line with the class name to 
/META-INF/services/org.springframework.cloud.CloudConnector! 
!!! 
• Cloud Foundry example:! 
org.springframework.cloud.cloudfoundry.CloudFoundryConnector 
! 
•Heroku example:! 
org.springframework.cloud.heroku.HerokuConnector 
35
Cloud Service Extensibility 
36
Cloud Service Extensibility 
36 
public interface ServiceInfo { 
public String getId(); 
}
Cloud Service Extensibility 
public interface ServiceInfoCreator<SI extends ServiceInfo, SD> { 
36 
public boolean accept(SD serviceData); 
! 
public SI createServiceInfo(SD serviceData); 
} 
public interface ServiceInfo { 
public String getId(); 
}
Registering Service Info Creators 
• Each Cloud Connector can choose any scheme it prefers 
! 
• Cloud Foundry Cloud Connector example 
/META-INF/services/org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator 
37
Registering Service Info Creators 
• Each Cloud Connector can choose any scheme it prefers 
! 
• Cloud Foundry Cloud Connector example 
/META-INF/services/org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator 
37 
org.springframework.cloud.cloudfoundry.MysqlServiceInfoCreator 
org.springframework.cloud.cloudfoundry.PostgresqlServiceInfoCreator 
org.springframework.cloud.cloudfoundry.RedisServiceInfoCreator 
org.springframework.cloud.cloudfoundry.MongoServiceInfoCreator 
org.springframework.cloud.cloudfoundry.AmqpServiceInfoCreator 
org.springframework.cloud.cloudfoundry.MonitoringServiceInfoCreator 
org.springframework.cloud.cloudfoundry.SmtpServiceInfoCreator 
org.springframework.cloud.cloudfoundry.OracleServiceInfoCreator
Framework extensibility 
• Mapping ServiceInfo to framework-specific service connector 
• RelationalServiceInfo -> DataSource 
• MongoServiceInfo -> MongoDbFactory 
• ... 
38 
public interface ServiceConnectorCreator<SC, SI extends ServiceInfo> { 
! 
SC create(SI serviceInfo, ServiceConnectorConfig serviceConnectorConfig); 
Class<SC> getServiceConnectorType(); 
! 
Class<?> getServiceInfoType(); 
}
Framework extensibility registration 
• Each framework may choose any mechanism! 
! 
• Spring Connection Creator example! 
/META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator 
39
Framework extensibility registration 
• Each framework may choose any mechanism! 
! 
• Spring Connection Creator example! 
/META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator 
39 
org.springframework.cloud.service.relational.MysqlDataSourceCreator 
org.springframework.cloud.service.relational.PostgresqlDataSourceCreator 
org.springframework.cloud.service.relational.OracleDataSourceCreator 
org.springframework.cloud.service.keyval.RedisConnectionFactoryCreator 
org.springframework.cloud.service.document.MongoDbFactoryCreator 
org.springframework.cloud.service.messaging.RabbitConnectionFactoryCreator 
org.springframework.cloud.service.smtp.MailSenderCreator
Demo 
Spring Cloud to Consume a Microservice 
40
Deploy to Cloud Foundry 
$ gradle assemble 
$ cf create-user-provided-service cities-ws 
-p '{"url": "http://cities-s12gx.cfapps.io/", "tag": "cities"}' 
$ cf push 
41 
--- 
applications: 
- name: cities-ui 
host: cities-ui-s12gx 
path: build/libs/spring-boot-cities-ui.war 
services: [ cities-ws ] 
env: 
SPRING_PROFILES_ACTIVE: cloud 
http://cities-ui-s12gx.cfapps.io
Spring Boot Integration 
42
Auto-configuration 
• Add spring-cloud dependencies in project 
• … that’s it 
! 
! 
• The same effect as adding @CloudScan 
43 
Available in Spring Boot 1.2.x
Spring Cloud starter 
! 
<dependency> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-cloud</artifactId> 
</dependency> 
44 
Available in Spring Boot 1.2.x
What’s next 
• Support for many more services 
• Elasticsearch 
• Memcache 
• Riak 
• Cassandra 
• Neo4j 
• ... 
• Support for other cloud platforms 
• Support for other frameworks? 
45
What’s next 
• Support for many more services 
• Elasticsearch 
• Memcache 
• Riak 
• Cassandra 
• Neo4j 
• ... 
• Support for other cloud platforms 
• Support for other frameworks? 
45 
Community Contributions Welcome!
Simplify Cloud Applications using 
Spring Cloud 
Ramnivas Laddad and Scott Frederick 
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.

More Related Content

What's hot

악성코드 개념 및 대응 기술 (사이버 게놈 기술)
악성코드 개념 및 대응 기술 (사이버 게놈 기술)악성코드 개념 및 대응 기술 (사이버 게놈 기술)
악성코드 개념 및 대응 기술 (사이버 게놈 기술)seungdols
 
The Future is Now: The ForgeRock Identity Platform, Early 2017 Release
The Future is Now: The ForgeRock Identity Platform, Early 2017 ReleaseThe Future is Now: The ForgeRock Identity Platform, Early 2017 Release
The Future is Now: The ForgeRock Identity Platform, Early 2017 ReleaseForgeRock
 
OpenStack Architecture
OpenStack ArchitectureOpenStack Architecture
OpenStack ArchitectureMirantis
 
SpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSASpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSAOracle Korea
 
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...Lucas Jellema
 
Introduction to Spring Cloud
Introduction to Spring Cloud           Introduction to Spring Cloud
Introduction to Spring Cloud VMware Tanzu
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container securityVolodymyr Shynkar
 
해외 사례로 보는 Billing for OpenStack Solution
해외 사례로 보는 Billing for OpenStack Solution해외 사례로 보는 Billing for OpenStack Solution
해외 사례로 보는 Billing for OpenStack SolutionNalee Jang
 
Cortex: Horizontally Scalable, Highly Available Prometheus
Cortex: Horizontally Scalable, Highly Available PrometheusCortex: Horizontally Scalable, Highly Available Prometheus
Cortex: Horizontally Scalable, Highly Available PrometheusGrafana Labs
 
Netflix Massively Scalable, Highly Available, Immutable Infrastructure
Netflix Massively Scalable, Highly Available, Immutable InfrastructureNetflix Massively Scalable, Highly Available, Immutable Infrastructure
Netflix Massively Scalable, Highly Available, Immutable InfrastructureAmer Ather
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developersPatrick Savalle
 
Container Security
Container SecurityContainer Security
Container SecuritySalman Baset
 
Microservices in Practice
Microservices in PracticeMicroservices in Practice
Microservices in PracticeKasun Indrasiri
 
Managing Terraform Module Versioning and Dependencies
Managing Terraform Module Versioning and Dependencies Managing Terraform Module Versioning and Dependencies
Managing Terraform Module Versioning and Dependencies Nebulaworks
 
Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automationMario Fusco
 
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...Chris Richardson
 

What's hot (20)

악성코드 개념 및 대응 기술 (사이버 게놈 기술)
악성코드 개념 및 대응 기술 (사이버 게놈 기술)악성코드 개념 및 대응 기술 (사이버 게놈 기술)
악성코드 개념 및 대응 기술 (사이버 게놈 기술)
 
The Future is Now: The ForgeRock Identity Platform, Early 2017 Release
The Future is Now: The ForgeRock Identity Platform, Early 2017 ReleaseThe Future is Now: The ForgeRock Identity Platform, Early 2017 Release
The Future is Now: The ForgeRock Identity Platform, Early 2017 Release
 
OpenStack Architecture
OpenStack ArchitectureOpenStack Architecture
OpenStack Architecture
 
SpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSASpringBoot and Spring Cloud Service for MSA
SpringBoot and Spring Cloud Service for MSA
 
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
 
Introduction to Spring Cloud
Introduction to Spring Cloud           Introduction to Spring Cloud
Introduction to Spring Cloud
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
 
해외 사례로 보는 Billing for OpenStack Solution
해외 사례로 보는 Billing for OpenStack Solution해외 사례로 보는 Billing for OpenStack Solution
해외 사례로 보는 Billing for OpenStack Solution
 
Cortex: Horizontally Scalable, Highly Available Prometheus
Cortex: Horizontally Scalable, Highly Available PrometheusCortex: Horizontally Scalable, Highly Available Prometheus
Cortex: Horizontally Scalable, Highly Available Prometheus
 
REST API
REST APIREST API
REST API
 
Netflix Massively Scalable, Highly Available, Immutable Infrastructure
Netflix Massively Scalable, Highly Available, Immutable InfrastructureNetflix Massively Scalable, Highly Available, Immutable Infrastructure
Netflix Massively Scalable, Highly Available, Immutable Infrastructure
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Container Security
Container SecurityContainer Security
Container Security
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
Microservices in Practice
Microservices in PracticeMicroservices in Practice
Microservices in Practice
 
MicroServices on Azure
MicroServices on AzureMicroServices on Azure
MicroServices on Azure
 
Prometheus and Grafana
Prometheus and GrafanaPrometheus and Grafana
Prometheus and Grafana
 
Managing Terraform Module Versioning and Dependencies
Managing Terraform Module Versioning and Dependencies Managing Terraform Module Versioning and Dependencies
Managing Terraform Module Versioning and Dependencies
 
Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automation
 
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
Oracle CodeOne 2019: Descending the Testing Pyramid: Effective Testing Strate...
 

Similar to Simplify Cloud Applications using Spring Cloud

Easy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applicationsEasy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applicationsJack-Junjie Cai
 
Cloud Application Blueprints with Apache Brooklyn by Alex Henevald
Cloud Application Blueprints with Apache Brooklyn by Alex HenevaldCloud Application Blueprints with Apache Brooklyn by Alex Henevald
Cloud Application Blueprints with Apache Brooklyn by Alex Henevaldbuildacloud
 
GE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTGE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTKai Zhao
 
Cloud Foundry for Spring Developers
Cloud Foundry for Spring DevelopersCloud Foundry for Spring Developers
Cloud Foundry for Spring DevelopersGunnar Hillert
 
Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014cornelia davis
 
Super-NetOps Source of Truth
Super-NetOps Source of TruthSuper-NetOps Source of Truth
Super-NetOps Source of TruthJoel W. King
 
Mobile App Development With IBM Cloudant
Mobile App Development With IBM CloudantMobile App Development With IBM Cloudant
Mobile App Development With IBM CloudantIBM Cloud Data Services
 
Connect + Docker + AWS = Bitbucket Pipelines
Connect + Docker + AWS = Bitbucket PipelinesConnect + Docker + AWS = Bitbucket Pipelines
Connect + Docker + AWS = Bitbucket PipelinesAtlassian
 
Custom Runtimes for the Cloud
Custom Runtimes for the CloudCustom Runtimes for the Cloud
Custom Runtimes for the CloudCloudBees
 
Multi-Container Applications Spanning Docker, Mesos and OpenStack
Multi-Container Applications Spanning Docker, Mesos and OpenStackMulti-Container Applications Spanning Docker, Mesos and OpenStack
Multi-Container Applications Spanning Docker, Mesos and OpenStackAndrew Kennedy
 
FIWARE Wednesday Webinars - Short Term History within Smart Systems
FIWARE Wednesday Webinars - Short Term History within Smart SystemsFIWARE Wednesday Webinars - Short Term History within Smart Systems
FIWARE Wednesday Webinars - Short Term History within Smart SystemsFIWARE
 
PHP Buildpacks in the Cloud on Bluemix
PHP Buildpacks in the Cloud on BluemixPHP Buildpacks in the Cloud on Bluemix
PHP Buildpacks in the Cloud on BluemixIBM
 
Cloud Foundry for PHP developers
Cloud Foundry for PHP developersCloud Foundry for PHP developers
Cloud Foundry for PHP developersDaniel Krook
 
TDC2016SP - Construindo Microserviços usando Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring CloudTDC2016SP - Construindo Microserviços usando Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring Cloudtdc-globalcode
 
Running Docker in Production
Running Docker in ProductionRunning Docker in Production
Running Docker in ProductionAndrew Kennedy
 
Microservices with kubernetes @190316
Microservices with kubernetes @190316Microservices with kubernetes @190316
Microservices with kubernetes @190316Jupil Hwang
 
PartnerSkillUp_Enable a Streaming CDC Solution
PartnerSkillUp_Enable a Streaming CDC SolutionPartnerSkillUp_Enable a Streaming CDC Solution
PartnerSkillUp_Enable a Streaming CDC SolutionTimothy Spann
 
Azure Stack Overview (Dec/2018)
Azure Stack Overview (Dec/2018)Azure Stack Overview (Dec/2018)
Azure Stack Overview (Dec/2018)Cenk Ersoy
 
AWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAmazon Web Services
 
Openstack Summit Vancouver 2018 - Multicloud Networking
Openstack Summit Vancouver 2018 - Multicloud NetworkingOpenstack Summit Vancouver 2018 - Multicloud Networking
Openstack Summit Vancouver 2018 - Multicloud NetworkingShannon McFarland
 

Similar to Simplify Cloud Applications using Spring Cloud (20)

Easy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applicationsEasy integration of Bluemix services with your applications
Easy integration of Bluemix services with your applications
 
Cloud Application Blueprints with Apache Brooklyn by Alex Henevald
Cloud Application Blueprints with Apache Brooklyn by Alex HenevaldCloud Application Blueprints with Apache Brooklyn by Alex Henevald
Cloud Application Blueprints with Apache Brooklyn by Alex Henevald
 
GE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTGE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoT
 
Cloud Foundry for Spring Developers
Cloud Foundry for Spring DevelopersCloud Foundry for Spring Developers
Cloud Foundry for Spring Developers
 
Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014Running your Spring Apps in the Cloud Javaone 2014
Running your Spring Apps in the Cloud Javaone 2014
 
Super-NetOps Source of Truth
Super-NetOps Source of TruthSuper-NetOps Source of Truth
Super-NetOps Source of Truth
 
Mobile App Development With IBM Cloudant
Mobile App Development With IBM CloudantMobile App Development With IBM Cloudant
Mobile App Development With IBM Cloudant
 
Connect + Docker + AWS = Bitbucket Pipelines
Connect + Docker + AWS = Bitbucket PipelinesConnect + Docker + AWS = Bitbucket Pipelines
Connect + Docker + AWS = Bitbucket Pipelines
 
Custom Runtimes for the Cloud
Custom Runtimes for the CloudCustom Runtimes for the Cloud
Custom Runtimes for the Cloud
 
Multi-Container Applications Spanning Docker, Mesos and OpenStack
Multi-Container Applications Spanning Docker, Mesos and OpenStackMulti-Container Applications Spanning Docker, Mesos and OpenStack
Multi-Container Applications Spanning Docker, Mesos and OpenStack
 
FIWARE Wednesday Webinars - Short Term History within Smart Systems
FIWARE Wednesday Webinars - Short Term History within Smart SystemsFIWARE Wednesday Webinars - Short Term History within Smart Systems
FIWARE Wednesday Webinars - Short Term History within Smart Systems
 
PHP Buildpacks in the Cloud on Bluemix
PHP Buildpacks in the Cloud on BluemixPHP Buildpacks in the Cloud on Bluemix
PHP Buildpacks in the Cloud on Bluemix
 
Cloud Foundry for PHP developers
Cloud Foundry for PHP developersCloud Foundry for PHP developers
Cloud Foundry for PHP developers
 
TDC2016SP - Construindo Microserviços usando Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring CloudTDC2016SP - Construindo Microserviços usando Spring Cloud
TDC2016SP - Construindo Microserviços usando Spring Cloud
 
Running Docker in Production
Running Docker in ProductionRunning Docker in Production
Running Docker in Production
 
Microservices with kubernetes @190316
Microservices with kubernetes @190316Microservices with kubernetes @190316
Microservices with kubernetes @190316
 
PartnerSkillUp_Enable a Streaming CDC Solution
PartnerSkillUp_Enable a Streaming CDC SolutionPartnerSkillUp_Enable a Streaming CDC Solution
PartnerSkillUp_Enable a Streaming CDC Solution
 
Azure Stack Overview (Dec/2018)
Azure Stack Overview (Dec/2018)Azure Stack Overview (Dec/2018)
Azure Stack Overview (Dec/2018)
 
AWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for GovernmentAWS Webcast - Build Agile Applications in AWS Cloud for Government
AWS Webcast - Build Agile Applications in AWS Cloud for Government
 
Openstack Summit Vancouver 2018 - Multicloud Networking
Openstack Summit Vancouver 2018 - Multicloud NetworkingOpenstack Summit Vancouver 2018 - Multicloud Networking
Openstack Summit Vancouver 2018 - Multicloud Networking
 

Recently uploaded

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Simplify Cloud Applications using Spring Cloud

  • 1. Simplify Cloud Applications using Spring Cloud Ramnivas Laddad and Scott Frederick © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 2. Agenda • Spring Cloud Basics • Application Config Options • Java config • XML config • Extensibility mechanism • Cloud Platforms • Cloud Services • Frameworks • Spring Boot Integration 2
  • 4. Cloud Apps Awareness 3 Application
  • 5. Container Cloud Apps Awareness 3 Application
  • 6. Container Cloud Apps Awareness 3 Application App Instance Information
  • 7. Container Cloud Apps Awareness 3 Application Service App Instance Information
  • 8. Container Cloud Apps Awareness 3 Application Service Services Information App Instance Information
  • 9. Cloud Apps Awareness: Cloud Foundry Instance Information { "limits": { "mem" : 512, "disk" : 1024, "fds" : 16384 }, "application_version":"5e6fe3f7-6900-4af8-8376-bf3223ce886b", "application_name":"hello-spring-cloud", "application_uris":["myapp.cfapps.io"], "version":"5e6fe3f7-6900-4af8-8376-bf3223ce886b", "name":"hello-spring-cloud", "space_name":"development", "space_id":"5f629937-1821-4f48-9eb4-8c67c70c0df0", "instance_id":"b84fa4cd1c75431486dec1609828ae36", "instance_index":0, "host":"0.0.0.0", "port":63202, "started_at_timestamp":1401394307, "state_timestamp":1401394307 } 4 VCAP_APPLICATION env variable
  • 10. Cloud Apps Awareness: Cloud Foundry Services { "elephantsql": [ { "name" : "inventory-db", "label" : "elephantsql", "tags" : ["relational","Data Store","postgresql"], "plan" : "turtle", "credentials" : { "uri" : "postgres://user:pass@babar.elephantsql.com:5432/db", "max_conns" : "5" } } ], "rediscloud": [ { "name" : "rediscloud-service", "label" : "rediscloud", "tags" : ["key-value","redis","Data Store"], "plan" : "25mb", "credentials" : { "hostname" : "pub-redis.garantiadata.com", "port" : "11853", "password" : "pass" } } ] } 5 VCAP_SERVICES env variable
  • 11. Cloud Apps Awareness: Heroku Instance Information • Individual env variables ! PORT 12345 ! DYNO web.1 ! 6
  • 12. Cloud Apps Awareness: Heroku Services • One environment variable per service ! HEROKU_POSTGRESQL_PURPLE_URL postgres://user:pass@host.amazonaws.com:5432/db ! REDISCLOUD_URL redis://rediscloud:pass@host.garantiadata.com:19038 REDISTOGO_URL redis://redistogo:pass@host.redistogo.com:9139 7
  • 13. Spring Cloud Goals • Abstraction over cloud services and application environment • Implementation for multiple cloud platforms • Cloud Foundry • Heroku • Local testing simulating a cloud-like environment • Extensibility without modifying the core code • Cloud Connector • Service Creator 8
  • 15. Scanning for services !! @Configuration @CloudScan public class CloudConfig { ! } 10
  • 16. Scanning for services !! @Configuration @CloudScan public class CloudConfig { ! } 10
  • 17. Taking over control @Configuration public class CloudConfig extends AbstractCloudConfig { @Bean public DataSource dataSource() { return connectionFactory().dataSource(); } ! @Bean public MongoDbFactory mongoDb() { return connectionFactory().mongoDbFactory(); } } 11
  • 18. Taking over control: Working with specific services @Configuration public class CloudConfig extends AbstractCloudConfig { @Bean public DataSource inventoryDataSource() { return connectionFactory().dataSource("inventory-service"); } ! @Bean public DataSource customerDataSource() { return connectionFactory().dataSource("customers-service"); } } 12
  • 19. Taking over control: Configuring Services @Configuration public class CloudConfig extends AbstractCloudConfig { @Bean public DataSource inventoryDataSource() { PoolConfig poolConfig = new PoolConfig(20, 200); ConnectionConfig connectionConfig = new ConnectionConfig("characterEncoding=UTF-8"); DataSourceConfig serviceConfig = new DataSourceConfig(poolConfig, connectionConfig); return connectionFactory().dataSource( "inventory-service", serviceConfig); } } 13
  • 20. Acquiring generic services @Configuration public class CloudConfig extends AbstractCloudConfig { @Bean public Search search() { return connectionFactory().service( "search-service", Search.class); } } 14
  • 21. Demo Spring Cloud on Cloud Foundry 15
  • 22. Deploy to Cloud Foundry $ gradle assemble $ cf create-service cleardb spark cities-db $ cf push 16 --- applications: - name: cities host: cities-s12gx path: build/libs/spring-boot-cities.jar services: - cities-db env: SPRING_PROFILES_ACTIVE: cloud http://cities-s12gx.cfapps.io/
  • 23. Demo Spring Cloud on Heroku 17
  • 24. Deploy to Heroku $ heroku create cities-s12gx --stack cedar --buildpack http:// github.com/heroku/heroku-buildpack-java.git $ heroku config:set SPRING_CLOUD_APP_NAME=spring-boot-cities $ heroku config:set SPRING_PROFILES_ACTIVE=cloud $ heroku addons:add heroku-postgresql:hobby-dev $ git push heroku master 18 http://cities-s12gx.herokuapp.com/
  • 26. Scanning for services 20 <cloud:service-scan/>
  • 27. Taking over control 21 <cloud:data-source/> ! <cloud:mongo-db-factory/> ! ...
  • 28. Taking over control: Specifying services 22 <cloud:data-source service-name="inventory-service"/> ! <cloud:data-source service-name="customers-service"/>
  • 29. Taking over control: Configuring Services 23 <cloud:data-source service-name="inventory-service"> <cloud:pool pool-size="20" max-wait-time="200"/> <cloud:connection properties="characterEncoding=UTF-8"/> </cloud:data-source>
  • 30. Acquiring generic services 24 <cloud:service service-name="search-service"/>
  • 31. Acquiring generic services 24 <cloud:service service-name="search-service"/> <cloud:service service-name="search-service" connector-type="com.example.Search"/>
  • 32. Services Supported • Cloud Foundry, Heroku, and Local connectors with Spring • MySQL, Postgres, Oracle • Redis • MongoDB • AMQP / RabbitMQ • SMTP • Pivotal CF connectors with Spring • Pivotal HD 25
  • 33. Demo Spring Cloud with Hadoop 26
  • 34. Explicit Cloud Config 27 @org.springframework.context.annotation.Configuration public class CloudConfig extends AbstractCloudConfig { @Bean public ConnectionFactory rabbitConnectionFactory() { return connectionFactory().rabbitConnectionFactory(); } @Bean public DataSource hawqDataSource() { return connectionFactory().dataSource("phd-service/hawq"); } ! @Bean public DataSource gemfirexdDataSource() { return connectionFactory().dataSource("phd-service/gemfirexd"); } @Bean public Configuration hadoopConfiguration() { return connectionFactory().service(Configuration.class); } }
  • 35. Consuming Service Beans: Explicit Config 28 @Autowired @Qualifier("hawqDataSource") DataSource hawqDataSource; @Autowired @Qualifier(“gemfirexdDataSource") DataSource gemfirexdDataSource; ! @Autowired ConnectionFactory rabbitConnectionFactory; ! @Autowired Configuration hadoopConfiguration; !!
  • 36. Cloud Config with Scanning 29 @Configuration @CloudScan public class CloudConfig { }
  • 37. Consuming Service Beans: Explicit Config 30 @Autowired @Qualifier("phd-service/hawq") DataSource hawqDataSource; @Autowired @Qualifier("phd-service/gemfirexd") DataSource gemfirexdDataSource; ! @Autowired ConnectionFactory rabbitConnectionFactory; ! @Autowired Configuration hadoopConfiguration;
  • 40. Axes of Extensibility 32 Cloud Platform
  • 41. Axes of Extensibility 32 Cloud Platform Cloud Services
  • 42. Axes of Extensibility 32 Cloud Platform Cloud Services Framework Support
  • 43. Service Connector Extensibility Overview ServiceInfo 33 CloudConnector ServiceConnectorCreator SSerevrivciec eC Cononnencetcotror
  • 44. Cloud Platform Extensibility 34 public interface CloudConnector { ! boolean isInMatchingCloud(); ApplicationInstanceInfo getApplicationInstanceInfo(); ! List<ServiceInfo> getServiceInfos(); }
  • 45. Registering Cloud Connector ! • Add a line with the class name to /META-INF/services/org.springframework.cloud.CloudConnector! !!! • Cloud Foundry example:! org.springframework.cloud.cloudfoundry.CloudFoundryConnector ! •Heroku example:! org.springframework.cloud.heroku.HerokuConnector 35
  • 47. Cloud Service Extensibility 36 public interface ServiceInfo { public String getId(); }
  • 48. Cloud Service Extensibility public interface ServiceInfoCreator<SI extends ServiceInfo, SD> { 36 public boolean accept(SD serviceData); ! public SI createServiceInfo(SD serviceData); } public interface ServiceInfo { public String getId(); }
  • 49. Registering Service Info Creators • Each Cloud Connector can choose any scheme it prefers ! • Cloud Foundry Cloud Connector example /META-INF/services/org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator 37
  • 50. Registering Service Info Creators • Each Cloud Connector can choose any scheme it prefers ! • Cloud Foundry Cloud Connector example /META-INF/services/org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator 37 org.springframework.cloud.cloudfoundry.MysqlServiceInfoCreator org.springframework.cloud.cloudfoundry.PostgresqlServiceInfoCreator org.springframework.cloud.cloudfoundry.RedisServiceInfoCreator org.springframework.cloud.cloudfoundry.MongoServiceInfoCreator org.springframework.cloud.cloudfoundry.AmqpServiceInfoCreator org.springframework.cloud.cloudfoundry.MonitoringServiceInfoCreator org.springframework.cloud.cloudfoundry.SmtpServiceInfoCreator org.springframework.cloud.cloudfoundry.OracleServiceInfoCreator
  • 51. Framework extensibility • Mapping ServiceInfo to framework-specific service connector • RelationalServiceInfo -> DataSource • MongoServiceInfo -> MongoDbFactory • ... 38 public interface ServiceConnectorCreator<SC, SI extends ServiceInfo> { ! SC create(SI serviceInfo, ServiceConnectorConfig serviceConnectorConfig); Class<SC> getServiceConnectorType(); ! Class<?> getServiceInfoType(); }
  • 52. Framework extensibility registration • Each framework may choose any mechanism! ! • Spring Connection Creator example! /META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator 39
  • 53. Framework extensibility registration • Each framework may choose any mechanism! ! • Spring Connection Creator example! /META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator 39 org.springframework.cloud.service.relational.MysqlDataSourceCreator org.springframework.cloud.service.relational.PostgresqlDataSourceCreator org.springframework.cloud.service.relational.OracleDataSourceCreator org.springframework.cloud.service.keyval.RedisConnectionFactoryCreator org.springframework.cloud.service.document.MongoDbFactoryCreator org.springframework.cloud.service.messaging.RabbitConnectionFactoryCreator org.springframework.cloud.service.smtp.MailSenderCreator
  • 54. Demo Spring Cloud to Consume a Microservice 40
  • 55. Deploy to Cloud Foundry $ gradle assemble $ cf create-user-provided-service cities-ws -p '{"url": "http://cities-s12gx.cfapps.io/", "tag": "cities"}' $ cf push 41 --- applications: - name: cities-ui host: cities-ui-s12gx path: build/libs/spring-boot-cities-ui.war services: [ cities-ws ] env: SPRING_PROFILES_ACTIVE: cloud http://cities-ui-s12gx.cfapps.io
  • 57. Auto-configuration • Add spring-cloud dependencies in project • … that’s it ! ! • The same effect as adding @CloudScan 43 Available in Spring Boot 1.2.x
  • 58. Spring Cloud starter ! <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cloud</artifactId> </dependency> 44 Available in Spring Boot 1.2.x
  • 59. What’s next • Support for many more services • Elasticsearch • Memcache • Riak • Cassandra • Neo4j • ... • Support for other cloud platforms • Support for other frameworks? 45
  • 60. What’s next • Support for many more services • Elasticsearch • Memcache • Riak • Cassandra • Neo4j • ... • Support for other cloud platforms • Support for other frameworks? 45 Community Contributions Welcome!
  • 61. Simplify Cloud Applications using Spring Cloud Ramnivas Laddad and Scott Frederick © 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.