项目反应器onerrorsume被卡住了

发布于 2025-01-26 01:32:37 字数 568 浏览 3 评论 0原文

我正在使用项目反应堆,并且我的流量很长,我会得到一个例外(当与杰克逊(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断肠人 2025-02-02 01:32:37

作为错误处理的一部分,您将返回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 and flatMap 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 use switchIfEmpty operator to provide another publisher.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文