You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by johncarlguthrie <jo...@gmail.com> on 2011/07/15 19:29:03 UTC

Way to have Camel process files in timestamp order?

Is there a way to determine which file is picked up by a route first when
there are several files in a directory? I looked into sortby and Sort, but
those seem to be for arranging the content of a single message/file, which
is not what I want. I am working on a Spring/Camel application that picks up
any file put into a certain directory for processing. The order of
processing is important, we need to always process the oldest file
(timestamp oldest) first. Any advice is appreciated.

--
View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4591558.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Way to have Camel process files in timestamp order?

Posted by Donald Whytock <dw...@gmail.com>.
Glad to help.  Looks like it would be hard to implement anyway...I
can't find a convenient way in Java to get a file's creation date,
even though AFAIK Windows and 'nix both have it.

On Fri, Jul 15, 2011 at 7:22 PM, johncarlguthrie
<jo...@gmail.com> wrote:
> Went with the suggestion of going by filename, and since there's already a
> script to move the files into the directory just had the script put a
> timestamp on during the move. Thank you for the assistance, kind sir.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4592662.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Way to have Camel process files in timestamp order?

Posted by johncarlguthrie <jo...@gmail.com>.
Went with the suggestion of going by filename, and since there's already a
script to move the files into the directory just had the script put a
timestamp on during the move. Thank you for the assistance, kind sir.

--
View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4592662.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Way to have Camel process files in timestamp order?

Posted by Donald Whytock <dw...@gmail.com>.
Sorry, not seeing that option.  Might be worth a JIRA.

Any way you can include the timestamp in the filename and sort on that?

On Fri, Jul 15, 2011 at 4:43 PM, johncarlguthrie
<jo...@gmail.com> wrote:
> You are quite right! Okay, now I have a slightly different problem. Is there
> a flag to look for the time the file was created instead of when it was last
> modified? When moving a block of files into the directory, they all have the
> same modified time.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4592116.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Way to have Camel process files in timestamp order?

Posted by johncarlguthrie <jo...@gmail.com>.
You are quite right! Okay, now I have a slightly different problem. Is there
a flag to look for the time the file was created instead of when it was last
modified? When moving a block of files into the directory, they all have the
same modified time.

--
View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4592116.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Way to have Camel process files in timestamp order?

Posted by Donald Whytock <dw...@gmail.com>.
Should that perhaps be

<camel:from
uri="file:schedBatchInput?sortby=file:modified&amp;move=../archive/&amp;readLock=changed"
/>

?

On Fri, Jul 15, 2011 at 3:02 PM, johncarlguthrie
<jo...@gmail.com> wrote:
> Thinking I should include the line that I am trying to use, maybe I just have
> the order wrong or something. The line should pick up a file from
> schedBatchInput, and move it to archive when its done. I'm hoping this will
> pick up the OLDEST file first, I'd prefer to select by file create time than
> last modified time, but I did not see that as an option.
>
> <camel:from
> uri="file:schedBatchInput?sortby=file:modified?move=../archive/&amp;readLock=changed"
> />
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4591834.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Way to have Camel process files in timestamp order?

Posted by johncarlguthrie <jo...@gmail.com>.
Thinking I should include the line that I am trying to use, maybe I just have
the order wrong or something. The line should pick up a file from
schedBatchInput, and move it to archive when its done. I'm hoping this will
pick up the OLDEST file first, I'd prefer to select by file create time than
last modified time, but I did not see that as an option.

<camel:from
uri="file:schedBatchInput?sortby=file:modified?move=../archive/&amp;readLock=changed"
/>

--
View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4591834.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Way to have Camel process files in timestamp order?

Posted by johncarlguthrie <jo...@gmail.com>.
Well, that was my initial read as well, but using
sortBy=reverse:file:modified did not seem to change the order files were
picked up. I then ran files through with sortBy=file:modified and things
were processed in the same order as before, where I expected something to
change.

--
View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4591625.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Way to have Camel process files in timestamp order?

Posted by Donald Whytock <dw...@gmail.com>.
No, sortBy appears to act on files rather than file contents.  The
examples under the file component include sortBy=file:name and
sortBy=reverse:file:name.

sortBy uses the File Language
(http://camel.apache.org/file-language.html), which includes
"file:modified" as an option for specifying the file's last modified
date.

Don

On Fri, Jul 15, 2011 at 1:29 PM, johncarlguthrie
<jo...@gmail.com> wrote:
> Is there a way to determine which file is picked up by a route first when
> there are several files in a directory? I looked into sortby and Sort, but
> those seem to be for arranging the content of a single message/file, which
> is not what I want. I am working on a Spring/Camel application that picks up
> any file put into a certain directory for processing. The order of
> processing is important, we need to always process the oldest file
> (timestamp oldest) first. Any advice is appreciated.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Way-to-have-Camel-process-files-in-timestamp-order-tp4591558p4591558.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>