【发布时间】:2015-05-28 13:05:03
【问题描述】:
我有两条单独的路线。两条路线基本相同。不同的是源文件夹和目标文件夹。如果发生错误,两条路由都会抛出相同的异常。这我在一个 onException 块中捕获。 在此,我想根据实际路线将文件写入文件夹。所以我想基于 routeId 构建一个 choiche()....when(...) 。问题是,我怎样才能让 routeId 在何时使用它。 下面显示了一些我认为它如何工作的代码。但不是。也许有人有一个想法。
onException(SomeValidationException.class)
.handled(true)
.useOriginalMessage()
.choice()
.when(exchangeProperty("routeId").convertToString().isEqualTo("Route1"))
.to("file:data/error/Route1")
.when(exchangeProperty("routeId").convertToString().isEqualTo("Route2"))
.to("file:data/error/Route2")
.otherwise()
.log(LoggingLevel.ERROR, "I always get here")
.end();
from("file:data/in/Route1")
.routeId("Route1")
.routePolicy(getRoutingPolicy())
.to("direct:RouteWhichWillThrowException")
.to("file:data/out/Route1");
from("file:data/in/Route2")
.routeId("Route2")
.routePolicy(getRoutingPolicy())
.to("direct:RouteWhichWillThrowException")
.to("file:data/out/Route2");
【问题讨论】:
标签: routing apache-camel choice