Mastering Spring Cloud
上QQ阅读APP看书,第一时间看更新

An alternative – Consul

An interesting alternative for Netflix discovery and Spring distributed configuration seems to be Consul created by Hashicorp. Spring Cloud provides integrations with this popular tool for discovering and configuring services in your infrastructure. As usual, this integration can be enabled using a few simple common annotations and the only difference in comparison with an earlier presented solution is in configuration settings. In order to establish communication with a Consul server, its agent needs to be available for the application. It has to be able to run as a separated process, which is available by default at the http://localhost:8500 address. Consul also provides REST API, which can be directly used for registration, collecting a list of services, or configuration of properties.

To activate Consul Service Discovery we need to use the spring-cloud-starter-consul-discovery starter. After application startup and registration, a client would query Consul in order to locate other services. It supports both the client-side load balancer with Netflix Ribbon and dynamic router and filter with Netflix Zuul.