Apache Camel multicast, exception and Aggregation strategy

元气小坏坏 提交于 2019-12-11 04:47:14

问题


I define a complex route in which I had to to orchestrate different simple operations.

   from(cxfCartEndpoint).routeId("receiveCart")
    .to("log:com.sdmo.input?level="+LOG_LEVEL)
    .process(cartWSExtractProcessor)
    .to(loggingMesssagesPath+"?fileName=originalRequest${date:now:yyyyMMdd-HHmmss}.xml")
    .multicast(aggregationStrategy).stopOnException()
       .to("mock:doNothing","direct:copyItem","direct:XmlSave","direct:manageFinalResponse")
        .end()
     .to(loggingMesssagesPath+"?fileName=finalResponse${date:now:yyyyMMdd-HHmmss}.xml")
     .process(new ConvertCartResponseProcessor())
     .to("log:com.sdmo.output?level="+LOG_LEVEL)
     ;

The from endpoint is a cxf WS in POJO mode, and I need to keep his header to be able to proceed the response, so the purpose of my aggregation strategy is to keep the original header. I set the .stopOnException() option because I do not want to run step 2 if step 1 is not ok. I throw exception with the following way in subroutes :

.choice()
  .when(not(successResponsePredicate))
    .to("log:com.sdmo.Error?level="+LOG_LEVEL)
    .throwException(new Exception("copyItemError"))
  .otherwise()
    .to("mock:CopyItemSuccess")
 .end();

Now I want to handle the exception in the aggregation strategy and compute a suitable error message to my web-service response.

If I define an exception behavior with the onException the exchange does not return to the aggregation strategy, I think I had to remove the stopOnException option, but I don't know how configure my aggregation strategy to skip the following multicast step

来源:https://stackoverflow.com/questions/7317776/apache-camel-multicast-exception-and-aggregation-strategy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!