I have consul agent server on localhost:8500. Then I have a simple http server, which first registrates in consul
Consul client = Consul.builder().build(); // connect on localhost
AgentClient agentClient = client.agentClient();
String serviceId = "1";
Registration.RegCheck regCheck = ImmutableRegCheck.builder()
.http("localhost:8080/api/rocks/healthCheck")
.interval("5s")
.timeout("1s")
.build();
Registration service = ImmutableRegistration.builder()
.id(serviceId)
.name("myService")
.port(8080)
.check(regCheck) // registers with a TTL of 3 seconds
.tags(Collections.singletonList("tag1"))
.meta(Collections.singletonMap("version", "1.0"))
.build();
agentClient.register(service);
And I it answers on get request for "healthCheck"
@GetMapping(value = "/healthCheck")
public ResponseEntity<String> healthCheck() {
log.info("RocksApi.healthCheck");
return ResponseEntity.ok("ok");
}
But consuls's health checker still says that Check is now critical for my service