dubbo 提供者无法调用方法

问题表现:HTTP Status 500 - Request processing failed; nested exception is com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method getBrandList in the service com.xxx.sellergoods.service.xxxService. Tried 3 times of the providers [192.168.204.1:20881] (1/1) from the registry 192.168.1.127:2181 on the consumer 192.168.204.1 using the dubbo version 2.8.4. Last error is: Invoke remote method timeout. method: getBrandList, provider: dubbo://192.168.204.1:20881/com.xxx.sellergoods.service.xxxService?anyhost=true&application=yizhigou-manager-web&check=false&dubbo=2.8.4&generic=false&interface=com.xxx.sellergoods.service.xxxService&methods=getBrandList&pid=335616&revision=1.0-SNAPSHOT&side=consumer&timestamp=1596703619137, cause: Waiting server-side response timeout. start time: 2020-08-06 16:47:06.130, end time: 2020-08-06 16:47:07.132, client elapsed: 0 ms, server elapsed: 1002 ms, timeout: 1000 ms, request: Request [id=2, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=getBrandList, parameterTypes=[], arguments=[], attachments={path=com.yizhigou.sellergoods.service.BrandService, interface=com.xxx.sellergoods.service.xxxService, version=0.0.0}]], channel: /192.168.204.1:63194 -> /192.168.204.1:20881

    意思就是说无法调用这个提供者的getList方法。尝试调用了三次,仍然失败。

问题排查:

    1.首先确认提供者发接口发布到dubbo中

    2。确认dao层的注入是否完成

解决方案:

  1。没有序列化pojo类 在pojo类中实现序列化接口

在分布式环境下,当进行远程通信时,无论是何种类型的数据,都会以二进制的形式在网络上进行传送。序列化是一种将对象,以一连串的字节描述的过程,用于解决在对对象流进行读写时所引发的问题。

2.可能是由于网络延迟引起的问题,返回值还没返回。连接就关闭了。

        在service中加了一个超时的声明标签:@Service(timeout = 50000)

3.可是数据库连接问题,使用的jar包不匹配

     把mysql-connector-java-5.1.32换成mysql-connector-java-5.1.46

问题解决,很nice~~~~~~

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Dubbo是一个高性能的开源RPC框架,用于构建分布式服务架构。要调用Dubbo服务,首先需要做以下几个步骤: 1. 引入Dubbo依赖:在你的项目中,需要引入Dubbo的相关依赖。你可以在Maven等构建工具中添加Dubbo的依赖,例如: ```xml <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>x.x.x</version> </dependency> ``` 请确保将`x.x.x`替换为你要使用的Dubbo版本。 2. 配置Dubbo消费者:在你的项目配置文件中,需要配置Dubbo消费者的相关信息。这包括注册中心的地址、服务接口、负载均衡策略等。一个示例的Dubbo消费者配置如下: ```xml <dubbo:application name="consumer-app" /> <dubbo:registry address="zookeeper://localhost:2181" /> <dubbo:reference id="userService" interface="com.example.UserService" /> <dubbo:consumer check="false" /> ``` 在上面的示例中,我们指定了注册中心地址为本地ZooKeeper服务,并引用了一个名为`userService`的服务。 3. 调用Dubbo服务:在代码中,你可以通过获取`userService`的实例来调用Dubbo服务方法。你可以通过Spring的依赖注入或者通过Dubbo的API手动获取实例。 ```java @Service public class UserServiceConsumer { @Autowired private UserService userService; public void doSomething() { // 调用Dubbo服务方法 String result = userService.getUserInfo(123); System.out.println(result); } } ``` 在上面的示例中,我们通过自动注入获取了`userService`的实例,并调用了`getUserInfo`方法。 以上是一个简单的Dubbo消费者的调用过程。需要注意的是,你需要确保Dubbo提供者已经注册到相应的注册中心,并且提供者和消费者的接口、版本号等必须一致。此外,你还可以根据实际情况自定义Dubbo的配置和扩展。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值