使用try catch时,Apache Camel路由结束

 覃思慧_419 发布于 2023-02-12 18:11

我有一个有"to"条款的路线.如果发生一些异常,我已经使用try catch块将交换重定向到路由.我遇到的例外情况与客户端允许的最大并行连接数无关.似乎,当异常得到解决时,交换的每次重试都会在离开的地方进一步处理.我怎样才能结束有例外的路线.

以下是我的代码.

from("direct:hourlyFeedParts")
    .routeId("appnexus hourly downloader")
    .doTry()
        .process(AppNexusProcessor.getDownloadProcessor())
        .process(AppNexusProcessor.getNamingProcessor())
        .id("Appnexus Feed Downloader")
        .log("Downloading file ${file:name}")
        .to("{{appnexus.partsDestination}}")
        .log("Downloaded file ${file:name} to local")
    .doCatch(Exception.class)
        .to("direct:hourlyFeedParts")
    .end()
    .bean(AppNexusProcessor.class, "updateIdempotentList")
    .choice()
        .when(simple("${property.CamelSplitComplete} == true"))
        .split(beanExpression(AppNexusProcessor.class, "getAggregatorProcessor"))
        .to("direct:S3PreProcessor")
        .endChoice()
    .end();

我以为可能正在使用endParent()之后

.doCatch(Exception.class)
.to("direct:hourlyFeedParts")
  .endParent()

这是正确的方法吗?我无法理解文档中endParent()的确切用法.

1 个回答
  • 只需stop()doCatch()块的末尾添加:

    .doCatch(Exception.class)
        .to("direct:hourlyFeedParts")
        .stop()
    .end()
    

    2023-02-12 18:13 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有