Camel - “子路由”中的异常处理
Camel 显式处理两个“范围”的错误处理:
- 全局
- 每个路由
我遇到的问题是在“子路由”中抛出异常。例如,我有这个路由:
from("direct:sendToWebservice").
.processRef("massageBeforeSending").
.to("http://webservice.com").
.processRef("massageResponse");
然后我还有另外两个路由需要将消息发送到 Web 服务:
from(direct:fromSystemA").
.errorHandler(deadLetterChannel("direct:TellSystemA")).
.to("direct:sendToWebservice");
from(direct:fromSystemB").
.errorHandler(deadLetterChannel("direct:TellSystemB")).
.to("direct:sendToWebservice");
我希望发生的是,如果 Web 服务路由抛出异常,它会传播到调用者,并且系统 A 或系统 B 都会收到通知。我看不出有什么办法可以实现这一目标。
我觉得这将是一个常见的用例——以前有人遇到过它吗?
再次感谢您抽出时间,
罗伊
Camel explicitly handles two 'scopes' of error handling:
- Global
- per Route
The issue I'm having is exceptions thrown in a 'sub route'. For instance, I've got this route:
from("direct:sendToWebservice").
.processRef("massageBeforeSending").
.to("http://webservice.com").
.processRef("massageResponse");
Then I've got two other routes that need to send messages to the webservice:
from(direct:fromSystemA").
.errorHandler(deadLetterChannel("direct:TellSystemA")).
.to("direct:sendToWebservice");
from(direct:fromSystemB").
.errorHandler(deadLetterChannel("direct:TellSystemB")).
.to("direct:sendToWebservice");
What I would like to happen is, if the webservice route throws an exception, it's propagated up to the caller, and either system A or system B would be notified. I don't see a way to achieve this.
I feel like this would be a common use case - has anyone bumped up against it before?
Thanks again for your time,
Roy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从同事那里得到答案:子路由需要禁用它的错误处理:
这会强制 Camel 将错误传播到调用路由。
Got the answer from a colleague: The subroute needs to have it's error handling disabled:
This forces Camel to propagate the error to the calling route.