【问题标题】:How to prevent camel redeliver files from sftp in case of exception发生异常时如何防止骆驼从 sftp 重新传递文件
【发布时间】:2017-11-01 16:12:37
【问题描述】:

我有以下骆驼配置:

from("file://" + FTP_FILES + "?idempotent=true")
.process(new Processor() {
     @Override
     public void process(Exchange exchange) throws Exception {
         throw new RuntimeException("test");             
     }
 }).onException(Exception.class).maximumRedeliveries(0);

此代码在无限循环中工作并试图处理相同的文件。

是否可以配置骆驼只是忽略异常?

附言

我也试过

.onException(RuntimeException.class).continued(true);

.onException(RuntimeException.class).handled(true)

但结果相同

附言

我只想要与此代码提供的行为相同的行为:

from("file://" + FTP_FILES + "?idempotent=true")
.process(new Processor() {
     @Override
     public void process(Exchange exchange) throws Exception {
         try{ 
             throw new RuntimeException("test");
         } catch(RuntimeException e){
             // just ignore  
         }             
     }
 })

【问题讨论】:

  • 你用的是什么版本的骆驼
  • @Claus,新版本 - 2.20
  • @Claus Ibsen,确切地说,我使用 CAMEL_VERSION = "2.20.0"

标签: java spring exception-handling apache-camel spring-camel


【解决方案1】:

请参阅此单元测试,证明 hos 这是可能的:https://github.com/apache/camel/commit/fcd200c4e13c35bb9a63924bbc3e2d6a643c31cf

错误处理程序将捕获异常并处理它,文件使用者将文件视为处理成功,并将文件移动到.camel子文件夹(默认行为)。

【讨论】:

  • 配置方法中声明的所有路由都是全局设置吗?
  • 是的,如果您正在学习 Camel,那么请考虑选择 CiA 第二版或任何其他书籍。你可以学得更快。
猜你喜欢
  • 1970-01-01
  • 2019-08-31
  • 1970-01-01
  • 1970-01-01
  • 2020-10-21
  • 1970-01-01
  • 2018-08-15
  • 2016-12-04
  • 2022-01-11
相关资源
最近更新 更多