Apache Camel 2.10.7 - monitor deletion of files from file system

守給你的承諾、 提交于 2019-12-12 02:57:17

问题


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}"

This works great if I touch/update a file on the file system.

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?

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?


回答1:


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.

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

  • http://docs.oracle.com/javase/tutorial/essential/io/notification.html


来源:https://stackoverflow.com/questions/25484212/apache-camel-2-10-7-monitor-deletion-of-files-from-file-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!