Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
201 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use the option

sendEmptyMessageWhenIdle=true

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

http://camel.apache.org/file2

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.

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

For example to poll every 10th second instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...