New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
适配线程池延迟初始化 #875
Comments
请教几个问题:
|
可否实现在延迟启动成功后,再进行 |
进入长轮训代码 this.executor.schedule(() -> {
try {
// awaitApplicationComplete.await();
// if (CollectionUtil.isNotEmpty(cacheMap)) {
executorService.execute(new LongPollingRunnable());
// }
} catch (Throwable ex) {
log.error("Sub check rotate check error.", ex);
}
}, 1L, TimeUnit.MILLISECONDS); 长轮训代码 public void run() {
if (CollectionUtil.isEmpty(cacheMap)) {
awaitApplicationComplete.await();
}
serverHealthCheck.isHealthStatus();
......
} 改为在增加缓存时唤醒 public void addTenantListeners(String namespace, String itemId, String threadPoolId, List<? extends Listener> listeners) {
CacheData cacheData = addCacheDataIfAbsent(namespace, itemId, threadPoolId);
for (Listener listener : listeners) {
cacheData.addListener(listener);
}
awaitApplicationComplete.countDown();
} |
最早我在测试长轮询时,遇到过特殊情况,具体不太清楚了,需要等待所有动态线程池准备就绪才会触发监听逻辑。 而如果按照你这种方式的话,就不具备全部准备就绪这种特性了。 |
能否不改动长轮询全局准备就绪逻辑,而是就 |
以上,我个人还是觉得长轮训是必须进入的,在里面挂起可以方便后面唤醒,而在入口那里拦截,是不妥的。 |
那我没问题了,可以尝试进行改造,注意做好不同情况下测试即可。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
需求建议
在
hippo4j-spring-boot-start-example
配置文件中加入spring.main.lazy-initialization=true
客户端clientwork 长轮训线程进入阻塞,并未被唤醒
修改方式
CommandLineRunner
的bean,项目启动后唤醒客户端长轮训线程,去除事件监听器逻辑,健康检查等相关逻辑同步修改。2.1 因为客户端可能存在懒加载的bean,当
map.isEmpty()
时,依旧进入。2.2 长轮训方法中加入判断逻辑,再加入一层唤醒机制,当本地注册的
DynamicThreadPoolExecutor
不为空时,取消睡眠如果认为这的确需要去适配,稍后我会去实现他。
您的功能请求是否与问题有关?
描述你想要的功能
The text was updated successfully, but these errors were encountered: