Apache camel 失败时移动文件

Apache camel 失败时移动文件,apache-camel,Apache Camel,我正在尝试编写一个路径来扫描“input”目录,如果找到一个.gz文件,则将内容提取到辅助目录,如果发生错误(例如,corrupt.gz),则会将该文件移动到错误目录 实际发生的情况是,文件开始正确地写出内容,然后发生了一个错误-GZLIB异常,原始文件被正确地放在错误目录中,但“input”中的.gz没有因为该异常而被删除 因此,路由将持续打开,开始提取,然后使文件失败,并一直重复。当文件失败时,我需要它将文件从“input”目录中删除,这样它就不会被重新处理。我希望.to()到一个文件位置来

我正在尝试编写一个路径来扫描“input”目录,如果找到一个.gz文件,则将内容提取到辅助目录,如果发生错误(例如,corrupt.gz),则会将该文件移动到错误目录

实际发生的情况是,文件开始正确地写出内容,然后发生了一个错误-GZLIB异常,原始文件被正确地放在错误目录中,但“input”中的.gz没有因为该异常而被删除

因此,路由将持续打开,开始提取,然后使文件失败,并一直重复。当文件失败时,我需要它将文件从“input”目录中删除,这样它就不会被重新处理。我希望.to()到一个文件位置来实现这一点,因为它通常表现为移动

onException( Exception.class )
     .to( "file://error_directory" )
.end()

from( "file://input" )
.choice()
    .when( {filename matches *.gz} )
        {unzip Gzip contents}
        .to( "file://output" )
    .when( ) ... 
.end()

您可以直接在文件使用者的文件端点上使用
moveFailed
选项,而不是
onException
。然后,如果出现异常,原始文件将被移动

大概是

from( "file://input?moveFailed=error_directory" )
.choice()
    .when( {filename matches *.gz} )
        {unzip Gzip contents}
        .to( "file://output" )
    .when( ) ... 
.end()

您可以在Camel文档中阅读有关
moveFailed
的更多信息:

而不是
oneexception
您可以直接在文件使用者的文件端点上使用
moveFailed
选项。然后,如果出现异常,原始文件将被移动

大概是

from( "file://input?moveFailed=error_directory" )
.choice()
    .when( {filename matches *.gz} )
        {unzip Gzip contents}
        .to( "file://output" )
    .when( ) ... 
.end()

您可以在Camel文档中阅读有关
moveFailed
的更多信息:

而不是
oneexception
您可以直接在文件使用者的文件端点上使用
moveFailed
选项。然后,如果出现异常,原始文件将被移动

大概是

from( "file://input?moveFailed=error_directory" )
.choice()
    .when( {filename matches *.gz} )
        {unzip Gzip contents}
        .to( "file://output" )
    .when( ) ... 
.end()

您可以在Camel文档中阅读有关
moveFailed
的更多信息:

而不是
oneexception
您可以直接在文件使用者的文件端点上使用
moveFailed
选项。然后,如果出现异常,原始文件将被移动

大概是

from( "file://input?moveFailed=error_directory" )
.choice()
    .when( {filename matches *.gz} )
        {unzip Gzip contents}
        .to( "file://output" )
    .when( ) ... 
.end()

您可以在驼峰文档中阅读更多关于
moveFailed
的信息:

@Claus-Ibsen如果文件移动失败并且端点使用“moveFailed”,它会在日志中记录文件名吗?@Claus-Ibsen如果文件移动失败并且端点使用“moveFailed”,它会在日志中记录文件名吗?@Claus-Ibsen如果文件移动失败并且端点使用“moveFailed”,它会在日志中记录文件名吗?@Claus Ibsen如果文件移动失败并且端点使用“moveFailed”,它会在日志中记录文件名吗?