如何在带有 Java DSL 的路由中使用 Apache Camel 在 try catch 块中使用选择?
我有一种情况,我需要以下结构:
route-->from--> doTry-->choice-->when-->simple-->to-->otherwise-->to-->enddoTry-->docatch-->to-->enddocatch- -> 终点路线
截至目前,我尝试了以下几行:
.doTry()
.choice()
.when(header("CamelFileName").contains("xxxxx"))
.to()
.otherwise().to("controlbus:route?routeId=XXXX&action=stop")
.doCatch(java.lang.Exception.class)
.log("STOPPING ROUTE")
.to("controlbus:route?routeId=XXXX&action=stop&async=true")
但我收到“找不到符号”错误docatch()
您能否建议在 Java DSL 的 try catch 块中使用“选择”的方法?
试试这个。这应该工作
.doTry()
.choice()
.when(header("CamelFileName").contains("xxxxx"))
.to()
.otherwise()
.to("controlbus:route?routeId=XXXX&action=stop")
.endDoTry()
.doCatch(java.lang.Exception.class)
.log("STOPPING ROUTE")
.to("controlbus:route?routeId=XXXX&action=stop&async=true")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句