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:
<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:
cluster: default
server-addr: localhost
namespace:
Configuring the Registry on the Server Side
Add the corresponding configuration to registry.conf, and refer to other configuration options:
registry {
type = "nacos"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
}
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.