我在 localhost: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);
我它回答了“healthCheck”的获取请求
@GetMapping(value = "/healthCheck")
public ResponseEntity<String> healthCheck() {
log.info("RocksApi.healthCheck");
return ResponseEntity.ok("ok");
}
但是领事的健康检查器仍然说检查现在对我的服务至关重要
最佳答案
您的健康检查网址可能有误。在您的客户端构建器中,您输入“api/rocks/healthCheck”,但您的端点只能通过路径“/healthCheck”访问。
关于java - 领事健康检查员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62173549/