NacosServiceInstance.getInstanceId() is null

pull/2375/head
galaxy 3 years ago
parent 8719706e46
commit 5986556b6b

@ -24,11 +24,14 @@ import org.springframework.cloud.client.ServiceInstance;
/** /**
* @author xiaojing * @author xiaojing
* @author changjin wei()
*/ */
public class NacosServiceInstance implements ServiceInstance { public class NacosServiceInstance implements ServiceInstance {
private String serviceId; private String serviceId;
private String instanceId;
private String host; private String host;
private int port; private int port;
@ -42,6 +45,11 @@ public class NacosServiceInstance implements ServiceInstance {
return serviceId; return serviceId;
} }
@Override
public String getInstanceId() {
return instanceId;
}
@Override @Override
public String getHost() { public String getHost() {
return host; return host;
@ -71,6 +79,10 @@ public class NacosServiceInstance implements ServiceInstance {
this.serviceId = serviceId; this.serviceId = serviceId;
} }
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
public void setHost(String host) { public void setHost(String host) {
this.host = host; this.host = host;
} }

@ -33,6 +33,7 @@ import org.springframework.cloud.client.ServiceInstance;
/** /**
* @author <a href="mailto:echooy.mxq@gmail.com">echooymxq</a> * @author <a href="mailto:echooy.mxq@gmail.com">echooymxq</a>
* @author changjin wei()
**/ **/
public class NacosServiceDiscovery { public class NacosServiceDiscovery {
@ -92,6 +93,7 @@ public class NacosServiceDiscovery {
nacosServiceInstance.setHost(instance.getIp()); nacosServiceInstance.setHost(instance.getIp());
nacosServiceInstance.setPort(instance.getPort()); nacosServiceInstance.setPort(instance.getPort());
nacosServiceInstance.setServiceId(serviceId); nacosServiceInstance.setServiceId(serviceId);
nacosServiceInstance.setInstanceId(instance.getInstanceId());
Map<String, String> metadata = new HashMap<>(); Map<String, String> metadata = new HashMap<>();
metadata.put("nacos.instanceId", instance.getInstanceId()); metadata.put("nacos.instanceId", instance.getInstanceId());

Loading…
Cancel
Save