Mastering Spring Cloud
上QQ阅读APP看书,第一时间看更新

Cloud platform support

Pivotal Cloud Foundry is a cloud-native platform for deploying and managing modern applications. Pivotal Software, as some of you probably already know, is an owner of the Spring framework trademark. The patronage of a large, commercial platform is one of the important reasons for Spring's growing popularity. What is obvious is that PCF fully supports both Spring Boot's executable JAR files, and all of Spring Cloud microservices patterns such as Config Server, service registry, and circuit breaker. These types of tools can be easily run and configured using the marketplace available on the UI dashboard or client command line. Development for PCF is even simpler than with standard Spring Cloud application. The only thing we have to do is to include the right starters to project dependencies: 

  • spring-cloud-services-starter-circuit-breaker
  • spring-cloud-services-starter-config-client
  • spring-cloud-services-starter-service-registry

It's difficult to find an opinionated cloud framework that does not have support for AWS. The same is true for Spring Cloud. Spring Cloud for Amazon Web Services provides integration with the most popular web tools available there. This includes modules for communication with Simple Queueing Service (SQS),  Simple Notification Service (SNS), ElasticCache, and Relational Database Service (RDS) that offer engines such as Aurora, MySQL, or Oracle. The remote resources can be accessed using their name defined in the CloudFormation stack. Everything is opaque in well-known Spring convention and patterns. There are four main modules available:

  • Spring Cloud AWS Core: Included using the spring-cloud-starter-aws starter, provides core components enabling direct access to the EC2 instance
  • Spring Cloud AWS Context: Delivers access to the Simple Storage Service, Simple E-mail Service, and caching service
  • Spring Cloud AWS JDBC: Included using starter spring-cloud-starter-aws-jdbc starter, provides data source lookup and configuration, which can be used with any data access technology supported by Spring
  • Spring Cloud AWS Messaging: Included using starter spring-cloud-starter-aws-messaging starter, allows an application to send and receive messages with SQS (point-to-point) or SNS (Publish/Subscribe)

There is another project that is worth mentioning although it is still at an early stage of development. That is Spring Cloud Function, which offers support for serverless architecture. Serverless is also known as FaaS (Function-as-a-Service), where a developer creates only very small modules that are deployed on containers fully managed by a third-party provider. Actually, Spring Cloud Functions implemented adapters for AWS Lambda and Apache OpenWhisk, the most popular FaaS providers. I will be following the development of this project designed for supporting a serverless approach. 

In this section, we should not forget about the Spring Cloud Connectors project, formerly known as Spring Cloud. It provides an abstraction for JVM-based applications deployed on a cloud platform. Actually, it has support for Heroku and Cloud Foundry, where our application could connect SMTP, RabbitMQ, Redis, or one of the available relational databases using one of the Spring Cloud Heroku Connectors and Spring Cloud Foundry Connector modules.