This is the 17th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

Seata transaction grouping

Transaction groups are seATA’s resource logic, similar to service instances. My_test_tx_group in file.conf is a transaction group.

In the file.conf configuration of the Seata Client, there is an attribute vgroup_mapping, which represents transaction group mapping. It is a Seata resource, similar to service instances, and mainly used to obtain service instances of the Seata Server by group.

How transaction grouping works

To configure transaction groups in your application, use the txServiceGroup parameter in the GlobalTransactionScanner constructor. This parameter can be configured in several ways:

  1. Get the value of spring.application.name by default + “-seata-service-group”
  2. In setA-spring-boot-starter, use seta.tx-service-group
  3. In the Spring Cloud Alibaba Seata, using Spring. Cloud. Alibaba. Seata. Tx – service – group configuration

The Seata client searches for the configuration value of service.vgroup_mapping.${txServiceGroup} in the specified location (configuration center or file.conf) according to the txServiceGroup of the application.

The application obtains the corresponding service list from the configuration center or file.conf based on the clusterName. The procedure for obtaining the service list for the TC cluster is as follows:

  1. Gets the transaction group Spring-Cloud-Ozx-repo configuration value AServicegroup
  2. Obtain the value of transaction group Agroup, which is spelled as service.vgroup_mapping.aserviceGroup, go to the configuration center to find the corresponding cluster name, and get the cluster name (default).
  3. Service. Default (cluster name). Grouplist, find the cluster name corresponding to the Seata Server service address: 10.0.100.254:8091

The implementation principle of transaction grouping is shown in the figure below:

Transaction group design purpose:

The client access server address is not directly use the service name, but a layer of more affairs grouping mapped to the cluster configuration, advantage grouping transaction isolation units can be used as resources, when a cluster fails, can realize rapid failover, grouping need to switch the corresponding fault can be realized to the service level, However, this operation requires sufficient server clusters.