You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by David Hoffer <dh...@gmail.com> on 2016/01/28 07:17:51 UTC

Custom sorting using the file component

I have a route that receives several different file types and the names
vary too but always contain a timestamp.  I need to process these
in timestamp order and planned to use sortBy=file:name, this worked fine in
testing but now that we are closer to production we are finding that the
file names often contain extra leading characters in addition to the the
timestamp, e.g

500432.[timestamp].dat

Since the leading 6 characters are random and completely unrelated to the
timestamp it completely throws off the sortBy=file:name approach.

Is there a way I can specify custom rules to use to determine what Camel
should use when doing the sort?  The rules would have to be per file type
as the name structure varies by type.

Is anything like this possible?  Any workarounds?

-Dave

Re: Custom sorting using the file component

Posted by David Hoffer <dh...@gmail.com>.
Is it possible to use groovy or xml to configure this or does this have to
be java?  I'm at production site so using some configuration or script
would be preferred.
On Jan 27, 2016 11:50 PM, "Claus Ibsen" <cl...@gmail.com> wrote:

> Hi
>
> Yes implement your own sorter, see the sorter option
> http://camel.apache.org/file2
>
> On Thu, Jan 28, 2016 at 7:17 AM, David Hoffer <dh...@gmail.com> wrote:
> > I have a route that receives several different file types and the names
> > vary too but always contain a timestamp.  I need to process these
> > in timestamp order and planned to use sortBy=file:name, this worked fine
> in
> > testing but now that we are closer to production we are finding that the
> > file names often contain extra leading characters in addition to the the
> > timestamp, e.g
> >
> > 500432.[timestamp].dat
> >
> > Since the leading 6 characters are random and completely unrelated to the
> > timestamp it completely throws off the sortBy=file:name approach.
> >
> > Is there a way I can specify custom rules to use to determine what Camel
> > should use when doing the sort?  The rules would have to be per file type
> > as the name structure varies by type.
> >
> > Is anything like this possible?  Any workarounds?
> >
> > -Dave
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>

Re: Custom sorting using the file component

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yes implement your own sorter, see the sorter option
http://camel.apache.org/file2

On Thu, Jan 28, 2016 at 7:17 AM, David Hoffer <dh...@gmail.com> wrote:
> I have a route that receives several different file types and the names
> vary too but always contain a timestamp.  I need to process these
> in timestamp order and planned to use sortBy=file:name, this worked fine in
> testing but now that we are closer to production we are finding that the
> file names often contain extra leading characters in addition to the the
> timestamp, e.g
>
> 500432.[timestamp].dat
>
> Since the leading 6 characters are random and completely unrelated to the
> timestamp it completely throws off the sortBy=file:name approach.
>
> Is there a way I can specify custom rules to use to determine what Camel
> should use when doing the sort?  The rules would have to be per file type
> as the name structure varies by type.
>
> Is anything like this possible?  Any workarounds?
>
> -Dave



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2