文件组件(Apache 骆驼)delete=true 参数在 Windows 中不起作用 [英] File component(Apache camel) delete=true parameter not working in windows

查看:22
本文介绍了文件组件(Apache 骆驼)delete=true 参数在 Windows 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache Camel File 组件在 Windows7 中无法正常工作,而在 Linux 中却没有任何问题.

The Apache Camel File component not working properly in Windows7, where as its working in Linux without any Problem.

我的要求:

文件处理后,必须从目录中删除文件.在 Windows 中,由于 .camelLock 文件无法正确删除.

After the file processing, the files must be deleted from the Directory. In Windows, because of .camelLock the files are not deleting properly.

多次尝试后,只有 Apache camel 可以从目录中删除文件.如果尝试未能从目录中删除文件,则会引发异常.

After Multiple attempts, then only Apache camel can delete the file from the Directory. If the attemt failed to delete the file from the Directory then its throwing an exception.

如果我在目录中只有一个文件,它可以正常工作,但如果我有多个文件,那么它会抛出异常.

If I have only a File in the Directory, it's working without any Problem, but if i have multiple Files then it's throwing an Exception.

应用环境:

我在 Tomcat 服务器中部署了 Apache camel 应用程序.

I deployed the Apache camel application in Tomcat Server.

Apache Camel 版本:2.17.1

Apache Camel version: 2.17.1

Apache 骆驼路线:

 <from uri="file:///var/opt/irs/message?delete=true" />
 <to uri="direct:file.storage.original" />

在 Windows 中,我收到以下错误:

In Windows I am receiving following Error:

1|2017-11-14 17:56:34,828|11-01-41|默认|警告
|是||o.a.c.c.f.GenericFileOnCompletion|file.analysis.input|错误在提交期间.交换 [ID-51741-1510678404569-9-22].引起的:[org.apache.camel.component.file.GenericFileOperationFailedException -无法删除文件:GenericFile[C:\var\opt\irs\message\661.zip]]org.apache.camel.component.file.GenericFileOperationFailedException:无法删除文件:GenericFile[C:\var\opt\irs\message\661.zip] atorg.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy.commit(GenericFileDeleteProcessStrategy.java:89)在org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:127)

1|2017-11-14 17:56:34,828|11-01-41|default|WARN
|yes||o.a.c.c.f.GenericFileOnCompletion|file.analysis.input|Error during commit. Exchange[ID-51741-1510678404569-9-22]. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot delete file: GenericFile[C:\var\opt\irs\message\661.zip]] org.apache.camel.component.file.GenericFileOperationFailedException: Cannot delete file: GenericFile[C:\var\opt\irs\message\661.zip] at org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy.commit(GenericFileDeleteProcessStrategy.java:89) at org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:127)

类似问题:Camel 2.15 文件锁 ,骆驼 2.14.2 不删除 Windows 上的文件 ,删除移动文件

推荐答案

在这种情况下,我忘记关闭文件输入流.所以这就是我在 Windows 中遇到问题的原因.

In this case, I forgot to close file input stream. so that's why I had a problem in Windows.

我不必要地将 InputStream 用于 Filecomponent.我删除了它,所有工作文件.

I am using InputStream unnecessarily for the Filecomponent. I removed it, everything working file.

InputStream input = CamelContextHelper.convertTo(context, InputStream.class, body);

如果有人遇到同样的问题,只需正确关闭文件 InputStream 或交叉检查您的代码并尝试用其他合适的替代解决方案替换它.

If anybody has same problem, just close the file InputStream properly or Cross-check your code and try to replace it with other proper alternative solution.

替代解决方案:

万一,如果您无法在代码中找到开放流,则将以下参数应用于 Apache 骆驼路线.性能会更好.

In case,if you are unable to find open streams in your code, then apply below parameters to Apache camel route. The performance would be better.

readLockCheckInterval=1&amp;readLockTimeout=3

就我而言,Windows 中的性能要好得多.

In my case Performance much better in windows.

这篇关于文件组件(Apache 骆驼)delete=true 参数在 Windows 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆