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实现RSA+AES自动接口解密的实战指南

《SpringBoot实现RSA+AES自动接口解密的实战指南》在当今数据泄露频发的网络环境中,接口安全已成为开发者不可忽视的核心议题,RSA+AES混合加密方案因其安全性高、性能优越而被广泛采用,本... 目录一、项目依赖与环境准备1.1 Maven依赖配置1.2 密钥生成与配置二、加密工具类实现2.1

使用Python的requests库调用API接口的详细步骤

《使用Python的requests库调用API接口的详细步骤》使用Python的requests库调用API接口是开发中最常用的方式之一,它简化了HTTP请求的处理流程,以下是详细步骤和实战示例,涵... 目录一、准备工作:安装 requests 库二、基本调用流程(以 RESTful API 为例)1.

Python调用LibreOffice处理自动化文档的完整指南

《Python调用LibreOffice处理自动化文档的完整指南》在数字化转型的浪潮中,文档处理自动化已成为提升效率的关键,LibreOffice作为开源办公软件的佼佼者,其命令行功能结合Python... 目录引言一、环境搭建:三步构建自动化基石1. 安装LibreOffice与python2. 验证安装

解决pandas无法读取csv文件数据的问题

《解决pandas无法读取csv文件数据的问题》本文讲述作者用Pandas读取CSV文件时因参数设置不当导致数据错位,通过调整delimiter和on_bad_lines参数最终解决问题,并强调正确参... 目录一、前言二、问题复现1. 问题2. 通过 on_bad_lines=‘warn’ 跳过异常数据3

解决RocketMQ的幂等性问题

《解决RocketMQ的幂等性问题》重复消费因调用链路长、消息发送超时或消费者故障导致,通过生产者消息查询、Redis缓存及消费者唯一主键可以确保幂等性,避免重复处理,本文主要介绍了解决RocketM... 目录造成重复消费的原因解决方法生产者端消费者端代码实现造成重复消费的原因当系统的调用链路比较长的时

深度解析Nginx日志分析与499状态码问题解决

《深度解析Nginx日志分析与499状态码问题解决》在Web服务器运维和性能优化过程中,Nginx日志是排查问题的重要依据,本文将围绕Nginx日志分析、499状态码的成因、排查方法及解决方案展开讨论... 目录前言1. Nginx日志基础1.1 Nginx日志存放位置1.2 Nginx日志格式2. 499

kkFileView启动报错:报错2003端口占用的问题及解决

《kkFileView启动报错:报错2003端口占用的问题及解决》kkFileView启动报错因office组件2003端口未关闭,解决:查杀占用端口的进程,终止Java进程,使用shutdown.s... 目录原因解决总结kkFileViewjavascript启动报错启动office组件失败,请检查of

RabbitMQ消费端单线程与多线程案例讲解

《RabbitMQ消费端单线程与多线程案例讲解》文章解析RabbitMQ消费端单线程与多线程处理机制,说明concurrency控制消费者数量,max-concurrency控制最大线程数,prefe... 目录 一、基础概念详细解释:举个例子:✅ 单消费者 + 单线程消费❌ 单消费者 + 多线程消费❌ 多

SpringBoot 异常处理/自定义格式校验的问题实例详解

《SpringBoot异常处理/自定义格式校验的问题实例详解》文章探讨SpringBoot中自定义注解校验问题,区分参数级与类级约束触发的异常类型,建议通过@RestControllerAdvice... 目录1. 问题简要描述2. 异常触发1) 参数级别约束2) 类级别约束3. 异常处理1) 字段级别约束

Python错误AttributeError: 'NoneType' object has no attribute问题的彻底解决方法

《Python错误AttributeError:NoneTypeobjecthasnoattribute问题的彻底解决方法》在Python项目开发和调试过程中,经常会碰到这样一个异常信息... 目录问题背景与概述错误解读:AttributeError: 'NoneType' object has no at