Nacos Registry

Nacos is an important registry implementation in the Seata component.

Prerequisites

Before integrating nacos-client into your Seata project, make sure that the Nacos service is already running in the background. If you are not familiar with the basic usage of Nacos, you can refer to the Nacos Quick Start guide. It is recommended to use Nacos version 1.2.0 or above.

Quick Start

The steps to integrate Nacos registry into Seata are very simple and can be roughly divided into “adding Maven dependencies” and “configuring the registry”.

Adding Maven Dependencies

First, you need to add the Maven dependency for nacos-client to your project’s pom.xml file. It is recommended to use Seata 1.4.0+:

  1. <dependency>
  2. <groupId>io.seata</groupId>
  3. <artifactId>seata-spring-boot-starter</artifactId>
  4. <version>latest version</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>com.alibaba.nacos</groupId>
  8. <artifactId>nacos-client</artifactId>
  9. <version>1.2.0 or above</version>
  10. </dependency>

Configuring the Registry on the Client Side

Add the corresponding configuration to application.yml, and refer to other configuration options:

  1. seata:
  2. registry:
  3. type: nacos
  4. nacos:
  5. application: seata-server
  6. namespace: ""
  7. server-addr: 127.0.0.1:8848
  8. group: SEATA_GROUP
  9. username: ""
  10. password: ""
  11. ##if use MSE Nacos with auth, mutex with username/password attribute
  12. #access-key: ""
  13. #secret-key: ""
  14. data-id: seata.properties
  15. tx-service-group: default_tx_group
  16. service:
  17. vgroup-mapping:
  18. default_tx_group: default

Configuring the Registry on the Server Side

Add the corresponding configuration to conf/application.yaml, and refer to other configuration options:

  1. seata:
  2. registry:
  3. type: nacos
  4. nacos:
  5. application: seata-server
  6. server-addr: 127.0.0.1:8848
  7. group: SEATA_GROUP
  8. namespace:
  9. cluster: default
  10. username:
  11. password:

After that, when you start the Seata-Server, you will see the server’s service appearing in the registry list on the Nacos console. Once the client is configured, you can start the application to experience the Seata service.

Tips: Make sure that the client and server are registered in the same namespace and group, otherwise the service will not be found.