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

相关文章

在 Spring Boot 中使用异步线程时的 HttpServletRequest 复用问题记录

《在SpringBoot中使用异步线程时的HttpServletRequest复用问题记录》文章讨论了在SpringBoot中使用异步线程时,由于HttpServletRequest复用导致... 目录一、问题描述:异步线程操作导致请求复用时 Cookie 解析失败1. 场景背景2. 问题根源二、问题详细分

解读为什么@Autowired在属性上被警告,在setter方法上不被警告问题

《解读为什么@Autowired在属性上被警告,在setter方法上不被警告问题》在Spring开发中,@Autowired注解常用于实现依赖注入,它可以应用于类的属性、构造器或setter方法上,然... 目录1. 为什么 @Autowired 在属性上被警告?1.1 隐式依赖注入1.2 IDE 的警告:

解决java.lang.NullPointerException问题(空指针异常)

《解决java.lang.NullPointerException问题(空指针异常)》本文详细介绍了Java中的NullPointerException异常及其常见原因,包括对象引用为null、数组元... 目录Java.lang.NullPointerException(空指针异常)NullPointer

Android开发中gradle下载缓慢的问题级解决方法

《Android开发中gradle下载缓慢的问题级解决方法》本文介绍了解决Android开发中Gradle下载缓慢问题的几种方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、网络环境优化二、Gradle版本与配置优化三、其他优化措施针对android开发中Gradle下载缓慢的问

关于Nginx跨域问题及解决方案(CORS)

《关于Nginx跨域问题及解决方案(CORS)》文章主要介绍了跨域资源共享(CORS)机制及其在现代Web开发中的重要性,通过Nginx,可以简单地解决跨域问题,适合新手学习和应用,文章详细讲解了CO... 目录一、概述二、什么是 CORS?三、常见的跨域场景四、Nginx 如何解决 CORS 问题?五、基

MySQL安装时initializing database失败的问题解决

《MySQL安装时initializingdatabase失败的问题解决》本文主要介绍了MySQL安装时initializingdatabase失败的问题解决,文中通过图文介绍的非常详细,对大家的学... 目录问题页面:解决方法:问题页面:解决方法:1.勾选红框中的选项:2.将下图红框中全部改为英

Java中将异步调用转为同步的五种实现方法

《Java中将异步调用转为同步的五种实现方法》本文介绍了将异步调用转为同步阻塞模式的五种方法:wait/notify、ReentrantLock+Condition、Future、CountDownL... 目录异步与同步的核心区别方法一:使用wait/notify + synchronized代码示例关键

Nginx启动失败:端口80被占用问题的解决方案

《Nginx启动失败:端口80被占用问题的解决方案》在Linux服务器上部署Nginx时,可能会遇到Nginx启动失败的情况,尤其是错误提示bind()to0.0.0.0:80failed,这种问题通... 目录引言问题描述问题分析解决方案1. 检查占用端口 80 的进程使用 netstat 命令使用 ss

shell脚本自动删除30天以前的文件(最新推荐)

《shell脚本自动删除30天以前的文件(最新推荐)》该文章介绍了如何使用Shell脚本自动删除指定目录下30天以前的文件,并通过crontab设置定时任务,此外,还提供了如何使用Shell脚本删除E... 目录shell脚本自动删除30天以前的文件linux按照日期定时删除elasticsearch索引s

Python调用Orator ORM进行数据库操作

《Python调用OratorORM进行数据库操作》OratorORM是一个功能丰富且灵活的PythonORM库,旨在简化数据库操作,它支持多种数据库并提供了简洁且直观的API,下面我们就... 目录Orator ORM 主要特点安装使用示例总结Orator ORM 是一个功能丰富且灵活的 python O