dubbo3 consumer消费端重启调用接口有30多秒等待问题

2023-12-29 21:44

本文主要是介绍dubbo3 consumer消费端重启调用接口有30多秒等待问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1、问题

Dubbo3 consumer消费端重启后,立即调用接口,需要等待有30多秒或者更久

之前没有加dubbo日志,所以 restful请求进去,直接卡住了,一直等待30多秒左右

加上dubbo日志后

2023-12-29 11:26:55.868 [main] INFO  o.s.scheduling.concurrent.ThreadPoolTaskExecutor traceId: - Initializing ExecutorService 'applicationTaskExecutor'
2023-12-29 11:26:55.957 [main] INFO  com.xxxx.common.restful.config.WebConfiguration traceId: - 增加拦截器
2023-12-29 11:26:57.505 [main] WARN  o.s.b.a.freemarker.FreeMarkerAutoConfiguration traceId: - Cannot find template location(s): [classpath:/templates/] (please add some templates, check your FreeMarker configuration, or set spring.freemarker.checkTemplateLocation=false)
2023-12-29 11:26:57.622 [main] INFO  org.apache.coyote.http11.Http11NioProtocol traceId: - Starting ProtocolHandler ["http-nio-8081"]
2023-12-29 11:26:57.654 [main] INFO  o.s.boot.web.embedded.tomcat.TomcatWebServer traceId: - Tomcat started on port(s): 8081 (http) with context path ''
2023-12-29 11:26:57.719 [main] INFO  o.apache.dubbo.config.deploy.DefaultModuleDeployer traceId: -  [DUBBO] Dubbo Module[1.1.1] is starting., dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:57.720 [main] INFO  o.a.dubbo.config.deploy.DefaultApplicationDeployer traceId: -  [DUBBO] Dubbo Application[1.1](xy-xxxx-common-restful) is starting., dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:57.720 [main] INFO  o.apache.dubbo.config.deploy.DefaultModuleDeployer traceId: -  [DUBBO] Dubbo Module[1.1.0] is starting., dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:57.721 [main] INFO  o.apache.dubbo.config.deploy.DefaultModuleDeployer traceId: -  [DUBBO] Dubbo Module[1.1.0] has started., dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:57.911 [main] INFO  org.apache.dubbo.metadata.MappingCacheManager traceId: -  [DUBBO] Successfully loaded mapping cache from file .mapping.xy-xxxx-common-restful, entries 0, dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:58.044 [main] INFO  org.apache.dubbo.qos.protocol.QosProtocolWrapper traceId: -  [DUBBO] qos won't be started because it is disabled. Please check dubbo.application.qos.enable is configured either in system property, dubbo.properties or XML/spring-boot configuration., dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:58.197 [main] INFO  c.a.n.p.auth.spi.client.ClientAuthPluginManager traceId: - [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.impl.NacosClientAuthServiceImpl success.
2023-12-29 11:26:58.198 [main] INFO  c.a.n.p.auth.spi.client.ClientAuthPluginManager traceId: - [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.ram.RamClientAuthServiceImpl success.
2023-12-29 11:26:58.379 [main] INFO  org.apache.dubbo.registry.nacos.NacosRegistry traceId: -  [DUBBO] Loaded registry cache file /home/www/.dubbo/dubbo-registry-xy-xxxx-common-restful-10.255.20.232-8848.cache, dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:58.420 [main] INFO  o.a.d.r.client.migration.MigrationRuleListener traceId: -  [DUBBO] Listening for migration rules on dataId xy-xxxx-common-restful.migration, group DUBBO_SERVICEDISCOVERY_MIGRATION, dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:58.585 [main] INFO  org.apache.dubbo.registry.nacos.NacosRegistry traceId: -  [DUBBO] Subscribe: consumer://172.17.0.1/com.xxxx.common.api.service.ElecSignDubboService?application=xy-xxxx-common-restful&background=false&category=providers,configurators,routers&check=false&dubbo=2.0.2&interface=com.xxxx.common.api.service.ElecSignDubboService&lazy=false&logger=slf4j&methods=signContractAfterOtherOpt,selectEsignLogPage,optEsignFlow,selectEsignMealLog,signContractOrFileToEsign,selectEsignPage,eSignCallBackHandle,selectEsignDetail,signAgreementToEsign,selectEsignMealDetail,mealConfig,lookFile&pid=22366&qos.enable=false&reference.filter=traceIdFilter&release=3.1.0&retries=0&side=consumer&sticky=false&timeout=60000&timestamp=1703820417861, dubbo version: 3.1.0, current host: 172.17.0.1
2023-12-29 11:26:58.629 [main] WARN  org.apache.dubbo.registry.nacos.NacosRegistry traceId: -  [DUBBO] Ignore empty notify urls for subscribe url consumer://172.17.0.1/com.xxxx.common.api.service.ElecSignDubboService?application=xy-xxxx-common-restful&background=false&category=providers,configurators,routers&check=false&dubbo=2.0.2&interface=com.xxxx.common.api.service.ElecSignDubboService&lazy=false&logger=slf4j&methods=signContractAfterOtherOpt,selectEsignLogPage,optEsignFlow,selectEsignMealLog,signContractOrFileToEsign,selectEsignPage,eSignCallBackHandle,selectEsignDetail,signAgreementToEsign,selectEsignMealDetail,mealConfig,lookFile&pid=22366&qos.enable=false&reference.filter=traceIdFilter&release=3.1.0&retries=0&side=consumer&sticky=false&timeout=60000&timestamp=1703820417861, dubbo version: 3.1.0, current host: 172.17.0.1, error code: 1-4. This may be caused by , go to https://dubbo.apache.org/faq/1/4 to find instructions. 
2023-12-29 11:26:58.633 [main] WARN  org.apache.dubbo.registry.nacos.NacosRegistry traceId: -  [DUBBO] Ignore empty notify urls for subscribe url consumer://172.17.0.1/com.xxxx.common.api.service.ElecSignDubboService?application=xy-xxxx-common-restful&background=false&category=providers,configurators,routers&check=false&dubbo=2.0.2&interface=com.xxxx.common.api.service.ElecSignDubboService&lazy=false&logger=slf4j&methods=signContractAfterOtherOpt,selectEsignLogPage,optEsignFlow,selectEsignMealLog,signContractOrFileToEsign,selectEsignPage,eSignCallBackHandle,selectEsignDetail,signAgreementToEsign,selectEsignMealDetail,mealConfig,lookFile&pid=22366&qos.enable=false&reference.filter=traceIdFilter&release=3.1.0&retries=0&side=consumer&sticky=false&timeout=60000&timestamp=1703820417861, dubbo version: 3.1.0, current host: 172.17.0.1, error code: 1-4. This may be caused by , go to https://dubbo.apache.org/faq/1/4 to find instructions. 

2、版本号

springboot 2.3.1.RELEASE
dubbo 3.1.0
nacos 2.1

3、问题原因

原因就在于,springboot在暴露端口后,去发布事件和监听时去把dubbo服务注册到naocs,一直在执行注册过程,所以,才会出现调用接口时等待

分析:
在SpringApplication.class run方法中,执行到this.refreshContext(context)方法中,然后到
AbstractApplicationContext.class中的refresh()方法中,finishRefresh(),方法中

protected void finishRefresh() {// Clear context-level resource caches (such as ASM metadata from scanning).clearResourceCaches();// Initialize lifecycle processor for this context.initLifecycleProcessor();// Propagate refresh to lifecycle processor first.getLifecycleProcessor().onRefresh();// Publish the final event.publishEvent(new ContextRefreshedEvent(this));// Participate in LiveBeansView MBean, if active.LiveBeansView.registerApplicationContext(this);
}

执行pubishEvent时dubbo服务去注册到nacos,这个时候,springboot的onRefresh()已经执行了,相当于已经暴露项目的端口了,
再去注册,这个时候,如果服务很多需要订阅的情况下,需要很久,所以,这块取决于服务有多少了。。

这样就会出现一个问题,既然项目模块已经暴露端口了,项目端口和接口已经对外可用状态了,但是服务还正在注册到nacos过程中,调用就会等待很久(取决于订阅的服务数量,我这有300多个)这个问题怎么解决呢??

查阅 了,很多的资料和dubbo官网的配置参数,nacos的配置参数,尝试了很多,是dubbo2和dubbo3的在spring加载时的机制变了,但这个问题怎么搞 ?

4、想要的预期结果

1、springboot暴露端口前,也就是在getLifecycleProcessor().onRefresh()前,dubbo服务注册到nacos完成
2、减少dubbo注册到nacos的过程时间
3、采用懒加载方式(但不太想使用这种方式)

5、重点来了,现在还没有解决

有空还在查dubb3和nacos2.1源码当中。。。
欢迎各位dubbo3熟悉的大佬给出解决方案
如果解决我会更新在文章中。。。。

外传

😜 原创不易,如若本文能够帮助到您的同学
🎉 支持我:关注我+点赞👍+收藏⭐️
📝 留言:探讨问题,看到立马回复
💬 格言:己所不欲勿施于人 扬帆起航、游历人生、永不言弃!🔥

这篇关于dubbo3 consumer消费端重启调用接口有30多秒等待问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/550818

相关文章

springboot下载接口限速功能实现

《springboot下载接口限速功能实现》通过Redis统计并发数动态调整每个用户带宽,核心逻辑为每秒读取并发送限定数据量,防止单用户占用过多资源,确保整体下载均衡且高效,本文给大家介绍spring... 目录 一、整体目标 二、涉及的主要类/方法✅ 三、核心流程图解(简化) 四、关键代码详解1️⃣ 设置

spring中的ImportSelector接口示例详解

《spring中的ImportSelector接口示例详解》Spring的ImportSelector接口用于动态选择配置类,实现条件化和模块化配置,关键方法selectImports根据注解信息返回... 目录一、核心作用二、关键方法三、扩展功能四、使用示例五、工作原理六、应用场景七、自定义实现Impor

MybatisPlus service接口功能介绍

《MybatisPlusservice接口功能介绍》:本文主要介绍MybatisPlusservice接口功能介绍,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友... 目录Service接口基本用法进阶用法总结:Lambda方法Service接口基本用法MyBATisP

MySQL 设置AUTO_INCREMENT 无效的问题解决

《MySQL设置AUTO_INCREMENT无效的问题解决》本文主要介绍了MySQL设置AUTO_INCREMENT无效的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参... 目录快速设置mysql的auto_increment参数一、修改 AUTO_INCREMENT 的值。

关于跨域无效的问题及解决(java后端方案)

《关于跨域无效的问题及解决(java后端方案)》:本文主要介绍关于跨域无效的问题及解决(java后端方案),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录通用后端跨域方法1、@CrossOrigin 注解2、springboot2.0 实现WebMvcConfig

Go语言中泄漏缓冲区的问题解决

《Go语言中泄漏缓冲区的问题解决》缓冲区是一种常见的数据结构,常被用于在不同的并发单元之间传递数据,然而,若缓冲区使用不当,就可能引发泄漏缓冲区问题,本文就来介绍一下问题的解决,感兴趣的可以了解一下... 目录引言泄漏缓冲区的基本概念代码示例:泄漏缓冲区的产生项目场景:Web 服务器中的请求缓冲场景描述代码

Java死锁问题解决方案及示例详解

《Java死锁问题解决方案及示例详解》死锁是指两个或多个线程因争夺资源而相互等待,导致所有线程都无法继续执行的一种状态,本文给大家详细介绍了Java死锁问题解决方案详解及实践样例,需要的朋友可以参考下... 目录1、简述死锁的四个必要条件:2、死锁示例代码3、如何检测死锁?3.1 使用 jstack3.2

解决JSONField、JsonProperty不生效的问题

《解决JSONField、JsonProperty不生效的问题》:本文主要介绍解决JSONField、JsonProperty不生效的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录jsONField、JsonProperty不生效javascript问题排查总结JSONField

github打不开的问题分析及解决

《github打不开的问题分析及解决》:本文主要介绍github打不开的问题分析及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、找到github.com域名解析的ip地址二、找到github.global.ssl.fastly.net网址解析的ip地址三

MySQL版本问题导致项目无法启动问题的解决方案

《MySQL版本问题导致项目无法启动问题的解决方案》本文记录了一次因MySQL版本不一致导致项目启动失败的经历,详细解析了连接错误的原因,并提供了两种解决方案:调整连接字符串禁用SSL或统一MySQL... 目录本地项目启动报错报错原因:解决方案第一个:第二种:容器启动mysql的坑两种修改时区的方法:本地