update the Nacos instance by real group name, not use the default group name
@@ -41,6 +41,10 @@ import static org.springframework.util.ReflectionUtils.rethrowRuntimeException;
*/
public class NacosServiceRegistry implements ServiceRegistry<Registration> {
+ private static final String STATUS_UP = "UP";
+
+ private static final String STATUS_DOWN = "DOWN";
+
private static final Logger log = LoggerFactory.getLogger(NacosServiceRegistry.class);
private final NacosDiscoveryProperties nacosDiscoveryProperties;
@@ -119,7 +123,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
@Override
public void setStatus(Registration registration, String status) {
- if (!"UP".equalsIgnoreCase(status) && !"DOWN".equalsIgnoreCase(status)) {
+ if (!STATUS_UP.equalsIgnoreCase(status) && !STATUS_DOWN.equalsIgnoreCase(status)) {
log.warn("can't support status {},please choose UP or DOWN", status);
return;
}
@@ -128,7 +132,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
Instance instance = getNacosInstanceFromRegistration(registration);
- if ("DOWN".equalsIgnoreCase(status)) {
+ if (STATUS_DOWN.equalsIgnoreCase(status)) {
instance.setEnabled(false);
}
else {
@@ -138,7 +142,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
try {
Properties nacosProperties = nacosDiscoveryProperties.getNacosProperties();
nacosServiceManager.getNamingMaintainService(nacosProperties)
- .updateInstance(serviceId, instance);
+ .updateInstance(serviceId, nacosDiscoveryProperties.getGroup(), instance);
}
catch (Exception e) {
throw new RuntimeException("update nacos instance status fail", e);
