Skip to main content
Version: v1.8

Consul Registry

Consul is an important registry implementation in the Seata component.

This article is based on Seata 1.4.2 and registers Seata to Consul with file as the configuration center.

Consul version recommended is 1.8+. The following text uses Consul 1.11.2 as an example.


Before you register Seata to Consul, make sure that the Consul service is already running. If you are not familiar with the basic usage of Consul, you can refer to the Consul official documentation first.

If you just want to experience it quickly, you can also use the following docker command to start a Consul container and access the Consul console at http://localhost:8500.

docker run -d --name=consul -p 8500:8500 -p 8600:8600/udp consul:1.11.2 agent -dev -client= -ui

Quick Start

Integrating Consul registry into Seata is very simple, with a Server-side and a Client-side.

The Server-side only needs to configure the "registry".

The Client-side needs to add Maven dependencies and configure them.

Server-side configuration of registry

Download Seata 1.4.2 release and extract it.

Modify the corresponding configuration center in /conf/registry.conf, and refer to the rest of the configuration.

registry {
type = "consul"

consul {
# The cluster name registered to Consul, default is default
cluster = "default"
serverAddr = ""
aclToken = ""

Execute /bin/seata-server.bat (Windows) or /bin/ (Unix) to start Seata. The service will run on port 8091 locally.

Go to the Consul console to check if Seata is registered successfully.

Client-side adding Maven dependencies

Taking a SpringBoot project as an example, add the following to the project's pom.xml

<version>latest version (Seata version)</version>

Client-side configuration

Add the corresponding registry to application.yml, and refer to the rest of the configuration.

# Transaction group configuration, default name is my_test_tx_group in version 1.4.2, will be changed to default_tx_group in version 1.5
# For more information about transaction groups, please refer to
tx-service-group: my_test_tx_group
# Mapping between transaction group and cluster
my_test_tx_group: default

After completing the client configuration, start the application and wait for a moment. When the following log appears, you can officially experience the Seata service.

register TM success. client version:1.4.2, server version:1.4.2,channel:[id: 0xa4675e28, L:/ - R:/]
register RM success. client version:1.4.2, server version:1.4.2,channel:[id: 0x408192d3, L:/ - R:/]
register success, cost 94 ms, version:1.4.2,role:RMROLE,channel:[id: 0x408192d3, L:/ - R:/]
register success, cost 94 ms, version:1.4.2,role:TMROLE,channel:[id: 0xa4675e28, L:/ - R:/]