apache / dubbo-spring-boot-project

Spring Boot Project for Apache Dubbo
https://dubbo.apache.org
Apache License 2.0
5.41k stars 1.88k forks source link

@Reference注解引用重试问题 #297

Closed uzdz closed 5 years ago

uzdz commented 5 years ago

项目:dubbo-spring-boot-starter 版本:0.2.0

设置: @Reference(version = "0.0.1", retries = 0) public EmployeeApi employeeApi;

单独设置某个引用超时后重试次数为0即关闭重试,但通过自测发现,设置retries为0是无效的,默认还会重试2次,通过debug调用链发现注解上的元素并没有起作用,那么请问如何设置@Reference注解元素起作用呢?

该问题是否是dubbo集成springboot的bug呢?

sarins commented 5 years ago

me 2

sarins commented 5 years ago
ConfigurableApplicationContext ctx = SpringApplication.run(ThirdpartyProxyApplication.class, args);
ConsumerConfig consumerConfig = ctx.getBean(ConsumerConfig.class);
if (null != consumerConfig) {
    consumerConfig.setCheck(false);
    consumerConfig.setRetries(0);
    consumerConfig.setTimeout(2000);
}

BTW, it may works, but i haven't tested it.

uzdz commented 5 years ago
ConfigurableApplicationContext ctx = SpringApplication.run(ThirdpartyProxyApplication.class, args);
ConsumerConfig consumerConfig = ctx.getBean(ConsumerConfig.class);
if (null != consumerConfig) {
    consumerConfig.setCheck(false);
    consumerConfig.setRetries(0);
    consumerConfig.setTimeout(2000);
}

BTW, it may works, but i haven't tested it.

It is indeed available,but I just want to retry a reference. @Reference annotations cannot be properly resolved. I think it's a bug.

Gnywin commented 5 years ago

我也是啊,在service 中设置 依旧无效,你有解决办法了吗?

uzdz commented 5 years ago

我也是啊,在service 中设置 依旧无效,你有解决办法了吗?

暂时没有解决,目前通过设置全局引用幂等解决的问题,可能社区维护人员最近比较忙吧。

sarins commented 5 years ago

I have no idea.

Gnywin commented 5 years ago

我也是啊,在service 中设置 依旧无效,你有解决办法了吗?

暂时没有解决,目前通过设置全局引用幂等解决的问题,可能社区维护人员最近比较忙吧。

I have no idea.

我也是啊,在service 中设置 依旧无效,你有解决办法了吗?

暂时没有解决,目前通过设置全局引用幂等解决的问题,可能社区维护人员最近比较忙吧。 两边使用 -1 试试,可以生效,你的应用幂等是怎么做的?我学习下

Gnywin commented 5 years ago

I have no idea.

use -1 set the reference and service

uzdz commented 5 years ago

在dubbo-spring-boot-starter这个项目中设置消费者调用生产者超时重试次数的解决方法有以下两种(经测试)。 1)通过设置消费端的yml或properties中的dubbo.consumer.retries的值为项目中所有调用生产者API设置重试次数。 2)通过在生产端中的某个需要设置retries的@Reference注解中设置@Reference(version = "0.0.1", retries = -1)来限制该对外暴露的API消费者调用超时时的重试次数。

uzdz commented 5 years ago

对于生产段设置@reference(version = "0.0.1", retries = -1)感觉有点别扭...

理论上来说,消费者调用生产者的API超时,重试次数应该由消费者中的@Reference中的retries来决定重试次数。而不是由生产端设置其生产的API对外暴露超时后的重试次数。

不知道是不是bug,如果社区人看到了这个issues,如果存在bug就请修复。

mercyblitz commented 5 years ago

Sorry for delayed response, it will be fixed in next release.

uzdz commented 5 years ago

Sorry for delayed response, it will be fixed in next release.

OK, can you mark it as bug? Because I will pay attention to the repair progress of this bug.

maventalker commented 5 years ago

retries = -1设置有效,但比较别扭。

在service引入层面设置不重试,即对service内部的所有方法不能重试,对于service内部一些幂等性的接口方法无法特殊设置吗?

mercyblitz commented 5 years ago

Please update dependencies in your Maven pom.xml, like this:

<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>0.2.0</version>
</dependency>

<!-- Dubbo -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.6.5</version>
</dependency>
<!-- Spring Context Extras -->
<dependency>
    <groupId>com.alibaba.spring</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>1.0.2</version>
</dependency>