|
|
@@ -1,7 +1,15 @@
|
|
|
package cn.reghao.tnb.admin.service;
|
|
|
|
|
|
+import com.alibaba.nacos.api.NacosFactory;
|
|
|
+import com.alibaba.nacos.api.PropertyKeyConst;
|
|
|
+import com.alibaba.nacos.api.config.ConfigService;
|
|
|
+import com.alibaba.nacos.api.config.listener.Listener;
|
|
|
+import com.alibaba.nacos.api.exception.NacosException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Properties;
|
|
|
+import java.util.concurrent.Executor;
|
|
|
+
|
|
|
/**
|
|
|
* @author reghao
|
|
|
* @date 2026-01-21 14:12:16
|
|
|
@@ -10,4 +18,49 @@ import org.springframework.stereotype.Service;
|
|
|
public class AdminService {
|
|
|
public void stat() {
|
|
|
}
|
|
|
+
|
|
|
+ public void nacos() throws InterruptedException, NacosException {
|
|
|
+ String serverAddr = "127.0.0.1";
|
|
|
+ String dataId = "search-dev";
|
|
|
+ String group = "DEFAULT_GROUP";
|
|
|
+ Properties properties = new Properties();
|
|
|
+ properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr);
|
|
|
+ ConfigService configService = NacosFactory.createConfigService(properties);
|
|
|
+ String content = configService.getConfig(dataId, group, 5000);
|
|
|
+ System.out.println("############################################################################");
|
|
|
+ System.out.println(content);
|
|
|
+ System.out.println("############################################################################");
|
|
|
+ configService.addListener(dataId, group, new Listener() {
|
|
|
+ @Override
|
|
|
+ public void receiveConfigInfo(String configInfo) {
|
|
|
+ System.out.println("receive:" + configInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Executor getExecutor() {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /*boolean isPublishOk = configService.publishConfig(dataId, group, "content");
|
|
|
+ System.out.println(isPublishOk);*/
|
|
|
+
|
|
|
+ //Thread.sleep(3000);
|
|
|
+ //content = configService.getConfig(dataId, group, 5000);
|
|
|
+ System.out.println("############################################################################");
|
|
|
+ //System.out.println(content);
|
|
|
+ System.out.println("############################################################################");
|
|
|
+
|
|
|
+ /*boolean isRemoveOk = configService.removeConfig(dataId, group);
|
|
|
+ System.out.println(isRemoveOk);
|
|
|
+ Thread.sleep(3000);*/
|
|
|
+
|
|
|
+ //content = configService.getConfig(dataId, group, 5000);
|
|
|
+ System.out.println("############################################################################");
|
|
|
+ //System.out.println(content);
|
|
|
+ System.out.println("############################################################################");
|
|
|
+
|
|
|
+ System.out.println("goto long sleep");
|
|
|
+ Thread.sleep(300_000);
|
|
|
+ }
|
|
|
}
|