[英]apache-camel error handler scope clarification
Below is an example route take from Camel In Action book. 以下是《骆驼在行动》一书中的路线示例。 There is one error handler at context scope and two route definitions.
在上下文范围内有一个错误处理程序,并且有两个路由定义。 My questions
我的问题
orderService.validate()
and orderService.enrich()
. orderService.validate()
即,来自orderService.validate()
和orderService.enrich()
引发的任何异常。 What if I want different error handler for exceptions that arise from validate()
and enrich()
methods? 如果我想要不同的错误处理程序来处理来自
validate()
和enrich()
方法的异常怎么办?
//context scope error handler //上下文范围错误处理程序
errorHandler(defaultErrorHandler() .maximumRedeliveries(2) .redeliveryDelay(1000) .retryAttemptedLogLevel(LoggingLevel.WARN)); //Route 1 from("file://target/orders?delay=10000") .beanRef("orderService", "toCsv") .to("mock:file") .to("seda:queue.inbox"); //Route 2 with route scope error handler from("seda:queue.inbox") .errorHandler(deadLetterChannel("log:DLC") .maximumRedeliveries(5).retryAttemptedLogLevel(LoggingLevel.INFO) .redeliveryDelay(250).backOffMultiplier(2)) .beanRef("orderService", "validate") .beanRef("orderService", "enrich") .to("mock:queue.order");
your assumptions on #1 & #2 are correct... 您对#1和#2的假设是正确的...
for #3, either define Exception Clauses to catch explicit exceptions thrown by your bean methods (OrderValidateException, EnrichException, etc.) or use inline try-catch blocks around each step in your route (I prefer the first approach myself) 对于#3,要么定义“ 异常子句”以捕获由bean方法抛出的显式异常(OrderValidateException,EnrichException等),要么在路由的每个步骤周围使用内联try-catch块(我更喜欢第一种方法)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.