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+
:
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
<version>latest version</version>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>1.2.0 or above</version>
</dependency>
Configuring the Registry on the Client Side
Add the corresponding configuration to application.yml, and refer to other configuration options:
seata:
registry:
type: nacos
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
group : "SEATA_GROUP"
namespace: ""
username: "nacos"
password: "nacos"
Configuring the Registry on the Server Side
Add the corresponding configuration to registry.conf, and refer to other configuration options:
registry {
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "127.0.0.1:8848"
group = "SEATA_GROUP"
namespace = ""
cluster = "default"
username = ""
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.