有没有一种方法可以将异常子句(onException)导入Camel Spring XML DSL中以在camelContext中使用它?
它应该像骆驼文档中说明的routContext这样工作。那里有一个文件,其中包含routeContext,您可以将其导入到主文件中并在camelContext中使用它:
<!-- import the routes from another XML file -->
<import resource="myCoolRoutes.xml"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- refer to a given route to be used -->
<routeContextRef ref="myCoolRoutes"/>
<!-- we can of course still use routes inside camelContext -->
<route id="inside">
<from uri="direct:inside"/>
<to uri="mock:inside"/>
</route>
</camelContext>
因此,我想要一个文件,将其命名为myCoolException.xml,并且应该有可能将其导入到我的主文件中。所以会是这样的:
<import resource="myCoolException.xml"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<exceptionContextRef ref="myCoolException"/>
...
</camelContext>
我的目标是模块化我的Camel文件,如果我想在不同的上下文中重用异常子句,请不要重复自己。
我不确定我们能做到这一点。但是您可以捕获并处理异常,然后转至常见的错误处理流程。所有骆驼上下文都应该可以访问该流。
喜欢,
onException(Exception.class).handled(true).to("direct-vm:commonErrorHandler")
您可以在“ direct-vm:commonErrorHandler”路由中定义通用的异常处理逻辑。您可以通过逻辑方式将多个direct-vm路由进行逻辑分组,以在一个常见的地方处理异常。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句