By Zihao Rao (Spring Cloud Alibaba Committer + Alibaba Cloud Intelligence Development Engineer)
According to the latest JVM EcoSystem Report 2021, the proportion of Spring framework users exceeds 80%, and Spring MVC reaches 1/3. This data shows that the relevant components of the Spring ecosystem still occupy an absolute leading position in the Java ecosystem.
The most widely used Spring ecosystem in China includes Spring Framework, Spring Boot, and Spring Cloud.
Framework originated in 2002. With the provision of dependency injection, aspect-oriented programming, and other capabilities, it subverts the traditional thick EJB enterprise application framework and gradually becomes the mainstream framework for Java enterprise application development. Although the Spring Framework has brought many advantages to Java development, people have gradually realized its cumbersome configuration and other defects.
In 2014, Spring Boot was made open-source by the Spring community. Through a series of established default configurations, Spring Framework has simplified the cumbersome configuration and other issues that are often criticized, allowing it to continue to develop.
In June 2015, in response to common problems in distributed microservice application development, the Spring community launched a Spring Cloud solution that includes distributed configuration registries, distributed messages, throttling and degradation, and other capabilities, which has played a major role in promoting the transformation of enterprises from monolithic applications to microservices.
In addition to the components shown above, Spring is a huge ecosystem today, consisting of 22 core projects in seven core areas: Web applications, microservices, response programming, cloud computing, Function Compute, event-driven, and batch tasks.
Currently, there are two main ways to use open-source RocketMQ in the Spring ecosystem. The first way is to use the dependencies and annotations provided by RocketMQ Spring. The other way is based on the Spring Cloud Stream provided by Spring Cloud Alibaba.
Thanks to the technical experience accumulated in handling the high-concurrency and high-traffic business of Taobao e-commerce over the past decade, Alibaba has developed a complete set of microservice solutions, including throttling and degradation, distributed registration configuration center, distributed messages, and distributed transactions.
In June 2015, after the first official version of Spring Cloud was released, it quickly became a hot spot in the microservice technology field. The development over the next one or two years proved that a complete set of microservice solutions based on Spring Cloud specifications, represented by Spring Cloud Netflix, had a great impact on the technological development of small and medium-sized enterprises. It has accelerated the transformation of a large number of small and medium-sized enterprises from monolithic applications to microservices.
Inspired by the Spring Cloud Netflix project, although the design concept of the Spring Cloud ecosystem is good, the relevant microservice solutions are not mature. It still lacks capabilities. Alibaba already has a complete set of solutions. Therefore, several colleagues (who were the first to participate in the Spring Cloud Alibaba) agreed immediately. In July 2018, they contributed a complete set of microservice solutions that Alibaba had polished for more than ten years to the Spring Cloud ecosystem through Spring Cloud Alibaba.
As shown in the figure, many external users can build microservice applications conveniently and at a low cost through Spring Cloud Alibaba and some differentiated storage and monitoring capabilities provided by Alibaba.
The dark orange part inside the circle in the preceding figure indicates Spring Cloud, which is a complete set of microservice solution standards based on SpringBoot. It consists of a series of related sub-projects, including distributed RPC calling capabilities defined by OpenFeign and RestTemplate, unified registration and configuration center capabilities for Spring Cloud Comments and Spring Cloud Config sub-projects, distributed message integration standards defined by Spring Cloud Stream sub-projects, and unified throttling and degradation capabilities defined by Spring Cloud CircuitBreak sub-projects.
Based on the standards in microservices, Spring Cloud Alibaba provides concrete implementation for microservice solutions from within Alibaba. It brings the implementation of Nacos, RocketMQ, Sentinel, and other microservice solutions to the Spring Cloud ecosystem and integrates some Alibaba Cloud platform services (such as SMS, distributed task scheduling, and Schedulex).
Spring Cloud Netflix (like the relationship between Spring Cloud Alibaba and Spring Cloud) is based on the specific implementation of Spring Cloud, a set of standards defined by microservices.
The Spring Cloud ecosystem has been large and prosperous. In addition to Spring Cloud Alibaba and Spring Cloud Netflix, ZooKeeper and Consul have contributed to the Spring Cloud community in the form of Spring Cloud ZooKeeper and Spring Cloud Consul projects as the implementation of registration and configuration center solutions.
In addition, Spring Cloud Kubernetes is an interesting sub-project in the cloud-native era. It enables Spring Cloud services to directly call Kubernetes-based microservices based on the service concept in Kubernetes.
As shown in the preceding figure, Spring Cloud Alibaba and Spring Cloud Netflix complement each other and play an important role in Spring Cloud's ecological integrity.
In addition, the popularity of the components of this solution has exceeded some components provided by Spring Cloud by default. For example, Nacos and RocketMQ have gradually become the de facto standards for distributed registration configuration centers and distributed messages in China. They are widely used in the production environment of a large number of small and medium-sized enterprises.
Besides Spring Cloud Alibaba and Spring Cloudnetflex, projects like Zookeeper and Consul have contributed to the Spring Cloud community in the form of Spring Cloud Zookeeper and Spring Cloud Consul as implementations of registration and configuration center solutions.
RocketMQ is the third-generation distributed messaging engine that was developed by the Alibaba middleware team in 2012 and was open-source. Its high performance, low latency, and anti-accumulation features stably have supported Alibaba's Double 11 trillion-level peak data business over the years. In 2016, Alibaba donated the RocketMQ project to the Apache Software Foundation. The following year, RocketMQ graduated from the Apache Software Foundation and became a top-level project in the Apache Software Foundation.
As shown in the preceding figure, a RocketMQ system in the production environment consists of four parts: Name Server cluster, Broker cluster, producer cluster, and consumer cluster. Broker cluster is used to store messages. Name Server cluster provides naming services to help message producers send messages to and subscribes to messages from specific broker clusters.
As one of the core middleware that supports the promotion of Taobao e-commerce, RocketMQ has proven reliability and throughput and provides two subscription modes (broadcast subscription and cluster subscription) and multiple message sending methods and multiple message types, including normal messages, ordered messages, scheduled messages, delayed messages, and transactional messages. These message types can help business developers easily address specific business demands.
As a distributed messaging solution defined by Spring Cloud, Spring Cloud Stream mainly consists of three parts: Message, Binder, and Bindings. Message defines a unified message structure, which can pass message data in the business system to the message structure in a specific message middleware through the unified message structure. The binder is the core of the Spring Cloud Stream and is responsible for integrating with external messages. For example, the RocketMQ Binder is required for integration with RocketMQ, and the Kafka Binder is required for integration with Kafka. Middleware indicates a specific message middleware, which can be RocketMQ or Kafka.
In the figure, the upper part is an application that uses a Spring Cloud Stream to connect to the message middleware. The middle Binder is similar to a connector, connecting the application to the middleware of a specific message, thus decoupling the application from the external message middleware.
Created by Binder, bindings is mainly responsible for the communication between the business system and the messaging middleware to complete the sending and receiving of messages.
The demo demonstrates the differences between the two methods of using RocketMQ.
The preceding figure shows the API for message sending provided by the RocketMQ Spring project, which is provided by the RocketMQ SpringBoot module. In order to use RocketMQ in the business system through Spring-related dependencies, you must introduce RocketMQ Spring-related dependencies to make configurations and send messages through API provided by the RocketMQ Spring project. The logic of the receiving module is similar. Instead of using API, annotations are provided through RocketMQ Spring.
Spring Cloud Alibaba operations on RocketMQ implement some core components of RocketMQ based on the standard of Spring Cloud Stream distributed messages in the Spring Cloud ecosystem. If Spring applications need to use RocketMQ through Spring Cloud Alibaba, you only need to introduce the module dependencies of SpringCloud Alibaba and then introduce Spring Cloud Stream modules.
The preceding figure shows the code for the producer of broadcast messages to continuously send 100 messages by the StreamBridge API provided by the Spring Cloud Stream. Message-related API does not rely on coupling with specific message middleware but constructs messages based on Spring-related Message objects.
When sending messages, you also need to make some configurations, mainly based on the content provided by the cloud to parse the configuration.
The preceding figure shows the code related to the sender of the message. There is no RocketMQ-related API. You only need to use the consumer method to subscribe to messages from RocketMQ and then print the results through log.info. Binding with specific messages is through configuration files, not in the business code. There is no tight coupling between related APIs and specific message middleware.
Next, send a message to see if the consumer can receive the message. Use RocketMQ-related modules to start NameServer and Broker to start message producers.
The preceding figure shows that both consumer1 and consumer2 have received messages. View the log and show that the message content is Hello RocketMQ 0 to Hello RocketMQ 99, a total of 100 messages.
In summary, the characteristic of Spring Cloud Alibaba mode is that there is no binding relationship with the specific message middleware. The implementation of the service code is all based on the public API provided by the Spring Cloud Stream to send and receive messages. The advantage is that RocketMQ-related classes are not used in the code to receive and send messages, and it is easy to switch between different middleware. For example, to switch from RocketMQ to Kafka, you only need to replace the RocketMQ-related dependencies in the application with Kafka's and modify some configurations. You do not need to modify the business code.
Compared with RocketMQ Spring, Spring Cloud Stream can decouple the business system from specific message middleware, make the system have better extensibility and maintainability, and have a longer life cycle.
After more than three years of development, Spring Cloud has released 27 versions, with the number of stars reaching 22.5K and fork and users reaching 7K and 23.7K, leading the relevant data of sub-projects domestically and internationally and even the official Spring Cloud.
In the future, the Spring Cloud Alibaba community will continue to enrich the project capacity and promote community development from the following two aspects:
First, community activities:
① The bi-weekly community meetings will discuss the issues and PR situation of the past two weeks on GitHub.
② The Chinese Academy of Sciences and Alibaba Open Source Office will jointly hold Open Source Summer, Programming Summer, and other activities. These activities are mainly aimed at students. Through summer vacation, under the one-on-one leadership of community mentors, some features are completed and contributed to the community, providing channels and opportunities for students to contact the open-source community.
③ There will be offline or online meetups to provide more communication opportunities for students inside and outside the community.
Second, development planning:
The first phase of Spring Cloud Alibaba's work is to enrich the Spring Cloud ecosystem so the vast number of external users can easily embrace the future of microservices. In the second phase, Spring Cloud Alibaba will continue to enable external users to make good use of microservices, build capabilities related to microservice governance and business high availability, and meet the high-level demands of users in the process of using microservices, including the following three aspects:
Finally, students interested in the Spring Cloud Alibaba project are welcome to join the community and participate in the future construction of Spring Cloud Alibaba.
508 posts | 48 followers
FollowAlibaba Developer - August 19, 2021
Alibaba Developer - July 8, 2021
Alibaba Cloud Native Community - December 1, 2021
Alibaba Developer - October 22, 2021
Alibaba Cloud Native Community - January 5, 2023
Aliware - October 20, 2020
508 posts | 48 followers
FollowApsaraMQ for RocketMQ is a distributed message queue service that supports reliable message-based asynchronous communication among microservices, distributed systems, and serverless applications.
Learn MoreA fully-managed Apache Kafka service to help you quickly build data pipelines for your big data analytics.
Learn MoreReach global users more accurately and efficiently via IM Channel
Learn MoreShort Message Service (SMS) helps enterprises worldwide build channels to reach their customers with user-friendly, efficient, and intelligent communication capabilities.
Learn MoreMore Posts by Alibaba Cloud Native Community