Technology Sharing

Analysis of the Apache Seata application-side startup process - registration center and configuration center modules

2024-07-08

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

This article comes from Apache Seata official documentation, welcome to visit the official website to view more in-depth articles.
This article comes fromApache Seata official documentation, welcome to visit the official website to view more in-depth articles.

Analysis of the Apache Seata application-side startup process - registration center and configuration center modules

Preface

In the process of Seata's application side (RM, TM) startup, the first thing to do is to establish communication with the coordinator side (TC), which is the premise for Seata to complete distributed transaction coordination. So in the process of Seata completing the application side initialization and establishing a connection with TC,How to find the cluster and address of the TC transaction coordinator?How to obtain various configuration information from the configuration moduleThis is exactly the focus of this article.

Give a limit

As a middleware-level underlying component, Seata is very cautious in introducing the specific implementation of third-party frameworks. Interested students can take a deep look at Seata's SPI mechanism to see how Seata uses a large number of extension points to invert the specific implementation of dependent components and rely on abstract interfaces. At the same time, in order to better integrate into the ecosystem derived from popular architectures such as microservices and cloud native, Seata has also actively integrated a number of mainstream microservice frameworks, registration centers, configuration centers, and the "leader" in the Java development framework world - SpringBoot based on the SPI mechanism. While ensuring the microkernel architecture, loose coupling, and scalability, it can also "get along" well with various components, making it easier to introduce Seata into environments using various technology stacks.

This article is to get closer to everyoneWhen Seata was first introduced for trialIn the following description, selectApplication sideThe restrictions are as follows: UseFile as Configuration Center and Registration Center, and based onSpringBootstart up.

With this limitation, let's go deep into the Seata source code and find out.

RM/TM initialization process of multiple modules alternating collaboration

exist Analysis of Seata client startup process (I)In the article, we analyzed the initialization of TM and RM on the Seata application side, and how the application side creates a Netty Channel and sends a registration request to the TC Server. In addition, during the RM initialization process, multiple other modules of Seata (registration center, configuration center, load balancing) also appeared one after another, collaborated with each other, and jointly completed the process of connecting to the TC Server.

When executing the method of reconnecting the Client to the TC Server: NettyClientChannelManager.Channreconnect(), you first need toTransaction GroupingGet a list of available TC Server addresses:

    /**
     * NettyClientChannelManager.reconnect()
     * Reconnect to remote server of current transaction service group.
     *
     * @param transactionServiceGroup transaction service group
     */
    void reconnect(String transactionServiceGroup) {
        List