coolbeevip commented on issue #454: fix when server.port=0, health check fail 
and also fix lose consul metadata, such as 'secure=false'
URL: https://github.com/apache/servicecomb-pack/pull/454#issuecomment-485140601
 
 
   @fengbaicanhe @WillemJiang 
   
   I suggest to modify it as follows
   
   ```java
     @EventListener
     public void listenInstanceRegisteredEvent(InstanceRegisteredEvent 
instanceRegisteredEvent){
       if(alphaServerPort == 0){
         if(instanceRegisteredEvent.getConfig() instanceof 
ConsulDiscoveryProperties){
           ConsulDiscoveryProperties properties = 
(ConsulDiscoveryProperties)instanceRegisteredEvent.getConfig();
           this.consuleInstanceId = 
formatConsulInstanceId(properties.getInstanceId());
           Response<List<CatalogService>> services = 
consulClient.getCatalogService(serviceName,null);
           if(services.getValue() != null){
             services.getValue().stream().filter(service ->
                 
service.getServiceId().equalsIgnoreCase(this.consuleInstanceId)).forEach(service
 -> {
   
               NewService newservice =  new NewService();
               newservice.setName(service.getServiceName());
               newservice.setId(service.getServiceId());
               List<String> tags = service.getServiceTags();
               tags.remove("alpha-server-port=0");
               tags.add("alpha-server-port="+actualAlphaServerPort);
               newservice.setTags(tags);
               consulClient.agentServiceRegister(newservice);
             });
           }
         }
       }
     }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to