【发布时间】:2017-01-20 12:24:00
【问题描述】:
我们在 Camel 中定义了一个具有拆分和聚合功能的路由,但无法在聚合器之后将异常传播回拆分。即使我们遇到异常,哪个原因是拆分运行
下面是不工作的代码
from("direct:MyRoute")
.routeId("MyRouteID")
.split().tokenize("\n", 1)
.streaming().stopOnException()
.choice()
.when(simple("${property.CamelSplitIndex} > 0"))
.unmarshal(domainDataFormat)
.choice()
.when(simple("${property.CamelSplitComplete}"))
.process(
new Processor()
{
@Override
public void process(Exchange exchange) throws Exception
{
exchange.getIn().getHeaders().put(Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE, true);
}
}
)
.end()
.aggregate(myAggregationStrategy).constant(true) //if i comment this line split will be stop on exception
.threads().executorService(executorService)
.process(myProcessor).end()
.end();
上面代码中的处理器(myProcessor)如下:
counter.incrementAndGet(); //atomic counter
if(counter.get()==3)
{
exchange.setException(new RuntimeException());
throw new RuntimeCamelException();
}
但是,当我从路由中删除聚合时,Split 能够在异常时停止路由。
【问题讨论】:
标签: apache-camel