项目反应器onerrorsume被卡住了
我正在使用项目反应堆,并且我的流量很长,我会得到一个例外(当与杰克逊(Jackson)一起解析JSON时)。问题是,即使我使用
.map(this::parser)
.onErrorResume(err -> {
log.error(myMsg);
return Mono.empty();
})
.flatMap(writeToPulsar)
.subscribe()
流程也不会继续。我确实看到了错误日志,并且流程不会引发异常,但是流程不会继续执行。有什么原因发生吗?
当我将代码更改为(不需要的).onerrorcontinue()
时,数据管道不会停止:
.map(this::parser)
.onErrorContinue((err, msg) -> {
log.error(myMsg);
})
.flatMap(writeToPulsar)
.subscribe()
I'm using project reactor and I have a very long flow in which I get an exception (when parsing a string to json with Jackson). The thing is that even though I use
.map(this::parser)
.onErrorResume(err -> {
log.error(myMsg);
return Mono.empty();
})
.flatMap(writeToPulsar)
.subscribe()
The flow won't continue. I do see the error log and the flow doesn't throw an exception, but the flow won't continue to get executed. Any reason for this to happen?
When I change the code to the (unwanted) .onErrorContinue()
, the data pipeline won't get stopped:
.map(this::parser)
.onErrorContinue((err, msg) -> {
log.error(myMsg);
})
.flatMap(writeToPulsar)
.subscribe()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为错误处理的一部分,您将返回
mono.empty()
,这意味着您的流将在不发出任何结果的情况下完成,并且flatmap
将不会执行。不确定预期的行为,但是如果您想继续流程 - 从
onerrorsume
而不是返回一些“默认”值,或者使用switchifempty
操作员提供另一个发布者。As a part of the error handling you are returning
Mono.empty()
and it means your flow will be completed without emitting any result andflatMap
will not be executed.Not sure about the expected behavior but if you want to continue the flow - return some "default" value from
onErrorResume
instead or useswitchIfEmpty
operator to provide another publisher.