如何回退项目电抗器通量的onErrorReturn错误元素?

时间:2018-09-12 20:42:42

标签: project-reactor reactive

让我们说我有一个通量,其中一个元素引发错误。

 Flux.just("aeiou","aeio").map(x -> {
           if(!x.endsWith("u")){throws Exception;}
           return x;})
      .onErrorReturn(/*This only accepts a new element*/)
      .map(x -> x+";")
      .subscribe();

 Flux.just("aeiou","aeio").map(x -> {
           if(!x.endsWith("u")){throws Exception;}
           return x;})
      .onErrorResume(/*This doesn't do the next steps*/)
      .map(x -> x+";")
      .subscribe();

我想要这样的东西

 Flux.just("aeiou","aeio").map(x -> {
           if(!x.endsWith("u")){throws Exception;}
           return x;})
      .onErrorReturn(x -> x + "u")
      .map(x -> x+";")
      .subscribe();

文档似乎有误 http://projectreactor.io/docs/core/release/reference/#_fallback_method

Flux.just("key1", "key2")
   .flatMap(k -> callExternalService(k)) 
   .onErrorResume(e -> getFromCache(k)); //k not resolved here

0 个答案:

没有答案