05 Understanding Spring Cloud & Spring Cloud Alibaba Projects

05 Understanding Spring Cloud & Spring Cloud Alibaba Projects #

In the previous sections, we roughly built the project framework and introduced some basic supporting functions to lay the foundation for future development. This section will introduce two projects: Spring Cloud and Spring Cloud Alibaba, in order to have a comprehensive understanding from a theoretical perspective and lay the groundwork for practical development. Spring Cloud Alibaba is a sub-project of Spring Cloud. Before introducing Spring Cloud Alibaba, let’s briefly talk about Spring Cloud.

Introduction to Spring Cloud #

Official Spring Cloud documentation: https://spring.io/projects/spring-cloud

Spring Cloud is a set of microservice technology system solutions composed of many components. The latest version is Hoxton. The version of Spring Cloud is not the usual major version or minor version in the form of numbers. The version of Spring Cloud is planned according to the order of London subway stations. The purpose is to better manage the versions of each Spring Cloud sub-project and avoid confusion between its version and the version of the sub-project. Therefore, it is particularly important to pay attention to the corresponding versions of the two projects to avoid unnecessary trouble in actual applications.

With the iteration and update of new versions, some low versions of Spring Cloud are no longer recommended for production. For example, the Brixton and Angel versions have been retired in 2017. img (The correspondence between the versions of Spring Cloud and Spring Boot, sourced from the official website) img (The correspondence between a certain version of Spring Cloud Greenwich and the versions of its sub-projects) Spring Cloud is based on Spring Boot and provides a complete set of microservice architecture solutions, including configuration management, service registration and discovery, routing, end-to-end invocation, load balancing, circuit breakers, global locks, distributed messaging, etc. For these functions, Spring Cloud provides multiple project choices, which can be glimpsed from the main project list on the official website. img One prominent sub-project in the image above is Spring Cloud Netflix, which was developed by Netflix and later integrated into the Spring Cloud family. It mainly provides modules such as service discovery, circuit breakers and monitoring, intelligent routing, and client-side load balancing. However, with the iteration of Spring Cloud, many Netflix components have entered maintenance mode. The most obvious one is the launch of Spring Cloud Gateway to replace the old Zuul component. As projects are added, old projects will also exit the stage. This is the normal rhythm of product iteration.

These sub-projects greatly enrich the application scope of Spring Cloud in the field of microservices, almost without the need for external components. With their own strength, they can build a fully ecological microservice architecture and better integrate with external infrastructure and operation and maintenance components.

Next, let’s introduce a new project that has emerged in the past two years: Spring Cloud Alibaba.

Introduction to Spring Cloud Alibaba #

Official website: https://github.com/alibaba/spring-cloud-alibaba Spring Cloud Alibaba is a sub-project of Spring Cloud, dedicated to providing a one-stop solution for microservice development. The project includes the necessary components for developing distributed application services, making it easy for developers to use these components to develop distributed application services through the Spring Cloud programming model. By simply adding some annotations and a small amount of configuration, Spring Cloud applications can be integrated into Alibaba’s distributed application solution, and distributed application systems can be quickly built using Alibaba middleware. The features of the project are shown in the following image: img It includes some key components:

  • Sentinel: It uses traffic as the entry point to protect the stability of services from multiple dimensions such as traffic control, circuit breaking and degradation, and system load protection. It is similar to Netflix’s Hystrix, but it is more lightweight in terms of implementation.
  • Nacos: It is a dynamic service discovery, configuration management, and service management platform that is easier to build cloud-native applications. It also has the functions of Netflix Eureka and Spring Cloud Config, but its UI operations are more user-friendly.
  • RocketMQ: It is an open-source distributed messaging system based on high availability distributed cluster technology. It provides low-latency and highly reliable message publishing and subscription services. It is currently maintained by the Apache organization.
  • Dubbo: Apache Dubbo™ is a high-performance Java RPC framework. Since it was incubated by the Apache organization, the community has been active and the ecosystem has become richer.
  • Seata: An open-source product from Alibaba, Seata is an easy-to-use, high-performance microservice distributed transaction solution that evolved from the early internal product Fescar.

All of the above components are open-source implementation solutions. The following components are combined with Alibaba Cloud’s product ecosystem to provide functionality. The subsequent case development scenarios do not introduce commercial products. If you need them, you can purchase them and directly integrate them using the corresponding API.

  • Alibaba Cloud ACM: ACM is an application configuration center product that centrally manages and pushes application configurations in a distributed architecture environment. It has similar functionality to the open-source product Nacos.
  • Alibaba Cloud OSS: Alibaba Cloud Object Storage Service (OSS) is a secure, cost-effective, and highly reliable cloud storage service provided by Alibaba Cloud. It allows you to store and access data of any type from any application, at any time, and from anywhere.
  • Alibaba Cloud SchedulerX: SchedulerX is a distributed task scheduling product developed by Alibaba Middleware Team. It provides millisecond-level, precise, highly reliable, and highly available scheduled (based on Cron expressions) task scheduling services.
  • Alibaba Cloud SMS: SMS provides global short message services, offering friendly, efficient, and intelligent interconnection capabilities to help enterprises quickly establish customer communication channels.

Version issues also need to be considered during usage. img (Screenshot from the Spring official website)

Introduction to Spring Boot #

Whether it is the Spring Cloud or Spring Cloud Alibaba projects, they are based on Spring Boot. Therefore, understanding Spring Boot first will help you better use these two projects. Spring Boot provides a large number of starter components, making it convenient for us to quickly apply the corresponding functionalities. It comes with an embedded application container (Tomcat, Jetty, and Undertow), eliminating the need to build war files for deployment. It follows the principle of convention over configuration and enables efficient application development.

The following link provides a comprehensive list of configuration parameters for Spring Boot, which I believe will be helpful to you. https://docs.spring.io/spring-boot/docs/2.2.4.RELEASE/reference/html/appendix-application-properties.html

This section introduces three key projects used in the course. It provides a simple conceptual understanding, and in the future, we will move on to development work with actual business scenarios. When using Spring Boot to build a project, it is generally run in the form of a jar file. However, some users may prefer to use a war package. So, how can we build a war package for a project built with Spring Boot?