领事健康检查员



我在本地主机上有领事代理服务器:8500。 然后我有一个简单的http服务器,它首先在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);

我回答了"健康检查"的请求

@GetMapping(value = "/healthCheck")
public ResponseEntity<String> healthCheck() {
log.info("RocksApi.healthCheck");
return ResponseEntity.ok("ok");
}

但是领事的健康检查员仍然说检查现在对我的服务至关重要

似乎您的运行状况检查 URL 可能是错误的。在客户端构建器中,您说"api/rocks/healthCheck",但您的终端节点只能通过路径"/healthCheck"访问。

最新更新