ServiceComb Pack 0.4.0 Integrated Discovery Service : Consul

1 minute read

ServiceComb Pack supports the registration of Alpha service instances to Consul from version 0.4.0, and Omega-side programs can visit Alpha with Consul

Run Consul

docker run -d -p 8500:8500 consul
  • Consul UI

Visit in the browser, you can see the following page indicates that Consul started successfully


Run Alpha

Enable registration to Consul with the parameter = true

java -jar alpha-server-0.4.0-exec.jar \
  --server.port=8090 \
  --alpha.server.port=8080 \
  --spring.datasource.url="jdbc:postgresql://" \
  --spring.datasource.username=saga-user \
  --spring.datasource.password=saga-password \ \ \ \ 

Note: Check out for Consul more details Spring Cloud Consul 2.x Spring Cloud Consul 1.x

After Alpha is launched, you can see that you have registered to Consul


Use curl You can see that Alpha’s gRPC address and port have been registered in Consul’s Tags

    "servicecomb-alpha-server-0-0-0-0-336b06581fb5b92ed91c7ade3fdafa88": {
        "ID": "servicecomb-alpha-server-0-0-0-0-336b06581fb5b92ed91c7ade3fdafa88",
        "Service": "servicecomb-alpha-server",
        "Tags": [
        "Meta": {},
        "Port": 8090,
        "Address": "",
        "Weights": {
            "Passing": 1,
            "Warning": 1
        "EnableTagOverride": false

Configuring the Omega side

ServiceComb Pack 0.4.0 Omega defaults use Spring Boot 2.x Spring and Cloud Consul 2.x, If your Omega side project base on Spring Boot 1.x you can use -Pspring-boot-1 to rebuild ServiceComb Pack to Spring Boot 1.x and Spring Cloud Consul 1.x

Modify the original omega project

add dependencies


Add the following to application.yaml

      	register: false
      port: 8500
      type: consul
  • property is set to the Consul server’s instance address, property is set to the Consul server’s instance port, property is not register yourself , check out Spring Boot’s  Spring Cloud Consul 2.x or Spring Cloud Consul 1.x for more details.

  • alpha.cluster.register.type=consul property is omega gets Alpha gRPC address from Consul

  • spring boot version compatible

If your project is not using spring boot 2.1.1, please refer to this list to add a compatible spring-cloud-starter-consul-discovery version

spring boot spring-cloud-starter-consul-discovery

Note: If you define parameter when start Alpha, You need to specify this service name in Omega via the parameter alpha.cluster.serviceId

Leave a Comment

Your email address will not be published. Required fields are marked *