Apache Camel 2.10.7-监视文件系统中文件的删除 [英] Apache Camel 2.10.7 - monitor deletion of files from file system
问题描述
我正在使用骆驼2.10.7,在servicemix方面取得了巨大的成功,将文件从本地文件系统馈送到我的应用程序.
I am using camel 2.10.7 with great success from servicemix to feed files from the local file system to my application.
文件应保留在文件系统上,因此我使用了类似的配置.
The files shall remain on the file system, hence I use a configuration like this one.
from uri ="file:../ange-data/vessels?noop = true& idempotentKey = $ {file:name}-$ {file:modified}"
from uri="file:../ange-data/vessels?noop=true&idempotentKey=${file:name}-${file:modified}"
如果我触摸/更新文件系统上的文件,这将非常有用.
This works great if I touch/update a file on the file system.
唯一的问题仍然存在:我如何才能在Java代码中检测到其他人或进程已将文件从文件系统中删除?
Only issue remains: how can I then in my Java code detect that a file has been removed from the file system by some other person or process?
通过研究手册页面 http://camel.apache.org/无法找到任何提示file-language.html 或 http://camel.apache.org/file2.html-但是我相信应该可以收到有关删除文件的消息?
Could not find any hint by studying the manual pages http://camel.apache.org/file-language.html or http://camel.apache.org/file2.html - but I believe it should be possible to get a message on file deletion?
推荐答案
您将需要使用Java 7 nio2,它具有文件监视程序api,您可以在其中添加/删除文件等时获得通知.
You would need to use Java 7 nio2 which has a file watcher api where you can get notifications when files are added/removed etc.
例如,在Web/SO中搜索有关此api的详细信息
Search the web / SO for details on this api, for example
这篇关于Apache Camel 2.10.7-监视文件系统中文件的删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!