关于canal消费者中引入dubbo消费者后调用dubbo接口为null问题
问题描述:
原来spring boot 2.x+canal服务引入dubbo服务消费者,配置都配过了,发现dubbo消费者每次请求都是报空指针异常。如下图
项目结构:
spring 2.x、canal消费者、kafa集成dubbo消费者服务
排查如下:
首先查看引入配置如下:
引入dubbo包
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
在配置文件中配置
# Base packages to scan Dubbo Components (e.g., @Service, @Reference)
dubbo.scan.basePackages= com.xx.canal.xx
# Dubbo Config properties
dubbo.application.name = canalconsumer
## ProtocolConfig Bean
dubbo.protocol.id=dubbo
dubbo.protocol.name=dubbo
dubbo.protocol.port=29952
dubbo.application.qos-enable=false
dubbo.provider.timeout=3000
dubbo.provider.threads=2000
dubbo.registry.protocol=zookeeper
dubbo.registry.address=xxx
在application添加dubbo注解
在调用包引入@Reference
@Reference
private IPopFlowConfigEsService popFlowConfigEsService;
问题寻找过程:
首先按照相关的网上尝试
将配置文件改成dubbo.xml
将注解改成其他
....
后面发现
原来dubbo
需要在@@Reference加上版本号
@Reference(version="1.0.0",timeout=5000)
相关的整合信息推荐:
https://blog.csdn.net/weixin_40288413/article/details/80792302?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522159368812419195162547488%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=159368812419195162547488&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_click~default-1-80792302.first_rank_ecpm_v3_pc_rank_v2&utm_term=springboot%E6%95%B4%E5%90%88dubbo
https://blog.csdn.net/J080624/article/details/84033579?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522159368812419195162547488%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=159368812419195162547488&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_click~default-2-84033579.first_rank_ecpm_v3_pc_rank_v2&utm_term=springboot%E6%95%B4%E5%90%88dubbo