This discovery bridge imports services from Consul into the Vert.x service discovery.
The bridge connects to a Consul agent (server) and periodically scan for services:
new services are imported
services in maintenance mode or that has been removed from consul are removed
This bridge uses the HTTP API for Consul. It does not export to Consul and does not support service modification.
The service type is deduced from
tags. If a
tag matches a known service type, this service type will be used.
If not, the service is imported as
http-endpoint is supported for now.
To use this Vert.x discovery bridge, add the following dependency to the dependencies section of your build descriptor:
Maven (in your
<dependency> <groupId>io.vertx</groupId> <artifactId>vertx-service-discovery-bridge-consul</artifactId> <version>3.3.3</version> </dependency>
Gradle (in your
Then, when creating the service discovery registers this bridge as follows:
ServiceDiscovery.create(vertx) .registerServiceImporter(new ConsulServiceImporter(), new JsonObject() .put("host", "localhost") .put("port", 8500) .put("scan-period", 2000));
You can configure the:
agent host using the
host property, it defaults to
agent port using the
port property, it defaults to 8500
scan period using the
scan-period property. The time is set in ms, and is 2000 ms by default