如何在 Apache Camel 中定义通过 ref 抛出的异常
必须在 XML 中定义的骆驼路由中抛出异常。发现 Camel 2.3 中提供了 throwException 语句,如下所示:
<throwException ref="forced"></throwException>
但是,我不知道如何定义要抛出的强制异常类。由于相同的异常可能会使用不同的异常消息抛出几次 - 最好知道 throwException 是否有其他形式的定义,以便异常类和异常消息就地定义。
Have to throw an exception in my camel route defined in XML. Found throwException
statement available from Camel 2.3 which looks like:
<throwException ref="forced"></throwException>
However, I don't know how to define forced
exception class to be thrown. Since same exception could be thrown couple of times with different exception messages - would be good to know if throwException
has some other form of definition so exception class and exception message are defined in-place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ref 只是对 a 的引用,所以你可以这样做
The ref is just a reference to a so you can do
从 2.16.0 版本开始,有更优雅的方法来做到这一点,并带有可选的异常消息:
Since version 2.16.0 there is more elegant way to do it, with optional exception message: