Apache Camel 2.10.7 - 监控文件系统中文件的删除 [英] Apache Camel 2.10.7 - monitor deletion of files from file system

查看:34
本文介绍了Apache Camel 2.10.7 - 监控文件系统中文件的删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用骆驼 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.

来自 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.htmlhttp://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.

例如在网络/SO 上搜索有关此 api 的详细信息

Search the web / SO for details on this api, for example

这篇关于Apache Camel 2.10.7 - 监控文件系统中文件的删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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