目前,resilience4j-all库中的DecorateConsumer.java不提供用于重试的修饰方法(仅支持断路器、RateLimiter和BulkHead)。
Retry.java类也不提供此选项
我有一个消费者函数public void call(String key),它在内部使用key的值执行rest调用。
但是resilience4j文档提到“你可以用一次重试来修饰任何Callable、Supplier、Runnable、Consumer、CheckedRunnable、CheckedSupplier、CheckedConsumer或CompletionStage。”
如何在resilience4j中使用重试来装饰消费者功能接口
发布于 2020-05-08 19:39:16
你可以这样做
String key = "key";
Runnable runnable = () -> helloWorldService.sayHelloWorldWithName(key);
Decorators
.ofRunnable(runnable)
.withRetry(Retry.ofDefaults("id"))
.run();或者只是
Runnable runnable = () -> helloWorldService.sayHelloWorldWithName(key);
retry.executeRunnable(runnable);https://stackoverflow.com/questions/61678094
复制相似问题