新增:1、ZhubClient 构造方法,支持 new 的方式初始化实例(一般在测试时使用)2、initClient 方法逻辑微调,确保实例完成初始化在执行队列数据处理

This commit is contained in:
梁显优 2023-05-25 17:53:37 +08:00
parent 4986fafdd2
commit c0a1c60cb6

View File

@ -56,10 +56,19 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer
};*/
private static Map<String, ZHubClient> mainHub = new HashMap<>(); // 127.0.0.1:1216 - ZHubClient
/*
public ZHubClient() {
logger.info("ZHubClient:" + (application != null ? application.getName() : "NULL"));
}*/
}
public ZHubClient(String name, Map<String, String> attr) {
this.APP_NAME = name;
this.addr = attr.get("addr");
this.groupid = attr.get("groupid");
this.auth = attr.get("auth");
this.initClient(null);
}
@Override
public void init(AnyValue config) {
@ -99,6 +108,7 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer
mainHub.put(addr, this);
}
CompletableFuture.runAsync(() -> {
// 消息 事件接收
new Thread(() -> {
if (!initSocket(0)) {
@ -198,7 +208,7 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer
}
}
}).start();
}).thenAcceptAsync(x -> {
// 定时调度事件已加入耗时监控
new Thread(() -> {
ExecutorService pool = Executors.newFixedThreadPool(1);
@ -308,6 +318,7 @@ public class ZHubClient extends AbstractConsumer implements IConsumer, IProducer
}
}
}).start();
});
return this;
}