发送电​​子邮件通知,如果没有文件从FTP拉 [英] Send an email notification if no files pulled from FTP

查看:188
本文介绍了发送电​​子邮件通知,如果没有文件从FTP拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过Spring用骆驼从FTP到本地磁盘上拉文件,然后处理它们了。我希望得到通知时的路线执行,但没有找到任何文件来拉。有没有办法与股票般地做到这一点?

I've been using Camel via Spring to pull files from an FTP to the local disk and then processing them. I'd like to be alerted when the route executes but doesn't find any files to pull. Is there a way to do this with stock camel?

如果没有;我在想什么做的是实施定制的验证的形式中间人。我然后从骆驼-ftp的组件到自定义验证路由,那么它可以做一些检查,如果需要的话发出通知,以及路线文件到文件组件要写入到文件系统。

If not; what I was thinking of doing was implementing a middle man in the form of a custom "validator". I'd then route from the camel-ftp component to the custom validator, then it could do some checks, send out notifications if needed, and route the file to the file component to be written to the filesystem.

我尝试添加该中间人,似乎如果没有FTP文件被发现,它甚至不会通知中间人。

I experimented with adding this middle-man and it seems that if no FTP files are found it won't even notify the middle-man.

推荐答案

您可以使用选项

sendEmptyMessageWhenIdle=true

截至记录(如FTP组件扩展了文件组件和inheirts其选项):

As documented at (as the ftp component extends the file component and inheirts its options):

http://camel.apache.org/file2

在使用sendEmptyMessageWhenIdle然后发送一个空的消息时,有没有的FTP文件进行轮询。

When using sendEmptyMessageWhenIdle then an empty message is sent when there is no ftp files to poll.

您就可以使用过滤器或基于内容的路由检测空文件,然后发送电子邮件。

You can then use a filter or content based router to detect the empty file and then send the email.

你也可以考虑延迟选项设置为较高的值,所以你不会尝试如此频繁轮询作为默认延迟为500ms。

Also you may consider setting the delay option to a higher value so you wont try to poll so frequently as by default the delay is 500 ms.

delay=10s

例如轮询每隔10秒吧。

For example to poll every 10th second instead.

这篇关于发送电​​子邮件通知,如果没有文件从FTP拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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