Мой единственный вопрос: почему ProductCommentFallbackFactory.class
не вызывается при превышении времени ожидания сетевого запроса? Пожалуйста, помогите мне, Спасибо, код как:
@FeignClient(value = "EurekaClientProductComment",fallbackFactory = ProductCommentFallbackFactory.class)
public interface ProductCommentFeign {
@GetMapping("/comments/product/{id}")
public List<Comment> getComments(@PathVariable("id") int id);
}
ProductCommentFallbackFactory.class
следующим образом:
@Service
public class ProductCommentFallbackFactory implements FallbackFactory<ProductCommentFeign> {
private static List<Comment> staticComment=new ArrayList<>();
private Logger logger= LoggerFactory.getLogger(ProductCommentRequestFallback.class);
static {
staticComment.add(new Comment(1,"request failed",23));
}
@Override
public ProductCommentFeign create(Throwable throwable) {
return new ProductCommentFeign() {
@Override
public List<Comment> getComments(int id) {
return staticComment;
}
};
}
}
global config:
feign.hystrix.enabled=true
feign.httpclient.enabled=false
feign.okhttp.enabled=true
feign.client.config.default.connect-timeout=10000
feign.client.config.default.read-timeout=10000
ошибка консоли:
2020-02-25 21:24:21.506 ERROR 29308 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/server] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: ProductCommentFeign#getComments(int) timed-out and fallback failed.] with root cause
java.util.concurrent.TimeoutException: null
at com.netflix.hystrix.AbstractCommand$8.call(AbstractCommand.java:585) ~[hystrix-core-1.4.3.jar:1.4.3]
at com.netflix.hystrix.AbstractCommand$8.call(AbstractCommand.java:566) ~[hystrix-core-1.4.3.jar:1.4.3]
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87) ~[rxjava-1.3.8.jar:1.3.8]
at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$1.run(AbstractCommand.java:871) ~[hystrix-core-1.4.3.jar:1.4.3]
at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:41) ~[hystrix-core-1.4.3.jar:1.4.3]
at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:37) ~[hystrix-core-1.4.3.jar:1.4.3]
at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable.run(HystrixContextRunnable.java:57) ~[hystrix-core-1.4.3.jar:1.4.3]
at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$2.tick(AbstractCommand.java:891) ~[hystrix-core-1.4.3.jar:1.4.3]
at com.netflix.hystrix.util.HystrixTimer$1.run(HystrixTimer.java:98) ~[hystrix-core-1.4.3.jar:1.4.3]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_181]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[na:1.8.0_181]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_181]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[na:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_181]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]