lulijun
lulijun

Reputation: 585

Can Spring Cloud Consul replace consul-client?

I'm learning Consul.Got confused by relation between Spring Cloud Consul and Consul Client.

I found that, in Spring boot applications, we can use @EnableDiscoveryClient to contact to a Consul Agent. But if I want to election a leader of my own service, can Spring Cloud Consul provides these interfaces?Or I need to relay on consul-client?

Upvotes: 0

Views: 338

Answers (1)

Jhon Mario Lotero
Jhon Mario Lotero

Reputation: 325

The election of the leader in the consul cluster is make of internal algorithm of consul based in RAFT that is an algoritm of consensum, for more information you can see:

https://www.consul.io/docs/internals/consensus.html

The clients of consul is a wrapper of API REST expoused by Consul, normaly you must have you consul servers behind of the load balancer and this url is that you configure in your clients for example in spring boot.

spring.cloud.consul.host = url_load_balancer
spring.cloud.consul.port = port_load_balancer

In conclusion the client can't manage the leader election of a consul cluster, but the closest approach that i find is:

https://www.consul.io/docs/guides/leader-election.html

i hope that it help you

Upvotes: 1

Related Questions