You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by JSmith <js...@gmail.com> on 2016/07/29 19:21:52 UTC

Running function at the end of FTP Polling

So I have a question (possibly simple):

Is there any built-in way to tell when a route is done polling for files and
done transferring them?

Basically, I need (would like to) run a function at the end of every polling
to update a value in a file.  This function would take the Modified On times
of every file that passed through GenericFileFilter implementation I have
written, find the largest (latest) Modified On time of the files that were
just polled, and update a timestamp that is being used as a filter value.

So that then the next time, any file earlier than the latest timestamp would
not be pulled again.

(I do know there is the whole IdempotentRepository that could just keep
track of file names and such and do this for me, but the boss said he didn't
want a potentially very large file sitting around and taking up disk space)



--
View this message in context: http://camel.465427.n5.nabble.com/Running-function-at-the-end-of-FTP-Polling-tp5785687.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Running function at the end of FTP Polling

Posted by JSmith <js...@gmail.com>.
Yeah I don't believe that's what I was looking for, but thanks!

However, I did get my problem solved.. maybe in a more roundabout way but it
works.

What I did was do a block like this in my Spring:
...
    <choice>
      <when>
        <simple>${headers.CamelBatchComplete} == true </simple>
	<bean ref="com.myClass" method="setModifiedTime"/>
      </when>
    </choice>
...
I'm assuming there's a nicer way to do this, but I was trying to keep things
as simple as possible and blatantly obvious and I think I achieved that,
haha. 

Thanks for the help!

PS.  I think it would be nice for someone to start going through the Camel
documentation website pages, there are all different font sizes and parts
missing and sometimes links take you to pages that have just a sentence or
so and that sentence has a link to somewhere else.  
I never would have found out that i can do the "<choice><when><simple>..."
stuff unless I had accidentally stumbled across it on StackOverFlow 



--
View this message in context: http://camel.465427.n5.nabble.com/Running-function-at-the-end-of-FTP-Polling-tp5785687p5785793.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Running function at the end of FTP Polling

Posted by souciance <so...@gmail.com>.
I am not sure if its 100% with what you want but you can also try enabling
the parameter sendEmptyMessageWhenIdle http://camel.apache.org/file2.html
which sends an empty message when no more files are to be polled. Based on
this once you get an empty message you know there is no more data to poll
and then take approppiate action.

On Mon, Aug 1, 2016 at 2:17 PM, JSmith [via Camel] <
ml-node+s465427n5785788h91@n5.nabble.com> wrote:

> Sorry still new to Camel,
>
> That makes sense, but is there a way from the GenericFile level to
> determine what Exchange the GenericFile is bound to?  I see there's a
> method to bind the File to a specific Exchange (bindToExchange(...) ), but
> there's no way to get it?
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Running-function-at-the-end-of-FTP-Polling-tp5785687p5785788.html
> To start a new topic under Camel - Users, email
> ml-node+s465427n465428h31@n5.nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Running-function-at-the-end-of-FTP-Polling-tp5785687p5785791.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Running function at the end of FTP Polling

Posted by JSmith <js...@gmail.com>.
Sorry still new to Camel,

That makes sense, but is there a way from the GenericFile level to determine
what Exchange the GenericFile is bound to?  I see there's a method to bind
the File to a specific Exchange (bindToExchange(...) ), but there's no way
to get it?




--
View this message in context: http://camel.465427.n5.nabble.com/Running-function-at-the-end-of-FTP-Polling-tp5785687p5785788.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Running function at the end of FTP Polling

Posted by DariusX <da...@gmail.com>.
Looking at the code, FTPConsumer implements a Batch consumer. This would
imply that the property "CamelBatchComplete" is being set to true on the
last Exchange of each batch. See the documentation for the File component:
http://camel.apache.org/file2.html

If you find this is true, please reply here and I'll update the
documentation for the ftp component too.


JSmith wrote
> Is there any built-in way to tell when a route is done polling for files
> and done transferring them?





--
View this message in context: http://camel.465427.n5.nabble.com/Running-function-at-the-end-of-FTP-Polling-tp5785687p5785705.html
Sent from the Camel - Users mailing list archive at Nabble.com.