camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: How to check that a file is empty
Date Thu, 15 Aug 2013 12:30:54 GMT
There should be non static methods on simple language to create a predicate.

On Thu, Aug 15, 2013 at 1:43 PM, Bengt Rodehav <bengt@rodehav.com> wrote:
> Thanks Claus.
>
> I do believe that the "PredicateBuilder.toPredicate" method I use does take
> an expression as a parameter and returns a Predicate. Which method should I
> have used?
>
> /Bengt
>
>
>
>
> 2013/8/15 Claus Ibsen <claus.ibsen@gmail.com>
>
>> Hi
>>
>> This is because you use the simple language "wrong" as you create an
>> expression, and NOT a predicate.
>>
>> I have logged a ticket to improve on this, so you have static methods
>> to easily create a predicate
>> https://issues.apache.org/jira/browse/CAMEL-6639
>>
>> On Thu, Aug 15, 2013 at 9:49 AM, Bengt Rodehav <bengt@rodehav.com> wrote:
>> > My original code that has been working for 2-3 years looks like this:
>> >
>> > *Predicate emptyFile =
>> > PredicateBuilder.toPredicate(SimpleLanguage.simple("${file:length} ==
>> 0"));
>> >
>> >
>> interceptFrom().when(emptyFile).setHeader("recipient").simple("file://${file:parent}/skipped/${date:now:yyyyMMdd}").recipientList(header("recipient")).stop();
>> > *
>> >
>> > For some reason, when using Camel 2.11.0, the above code causes all files
>> > to be skipped (even the non-empty ones). I have found another way of
>> doing
>> > this that works with Camel 2.11.0. It looks as follows:
>> >
>> > *
>> >
>> interceptFrom().when(header("CamelFileLength").isEqualTo(0)).setHeader("recipient").simple("file://${file:parent}/skipped/${date:now:yyyyMMdd}").recipientList(header("recipient")).stop();
>> > *
>> >
>> > I'm not sure what is happening. Since I have a workaround I'm OK but it
>> > seems like the behaviour of the SimpleLanguage has changed somehow. Could
>> > be a bug or at least something worth documenting.
>> >
>> > Any thoughts?
>> >
>> > /Bengt
>> >
>> >
>> >
>> >
>> >
>> > 2013/8/14 Bengt Rodehav <bengt@rodehav.com>
>> >
>> >> Thanks for the tip. It would probably be good enough although I also
>> want
>> >> to move the empty files to a dedicated directory to clearly show what
>> took
>> >> place.
>> >>
>> >> Do you know f the syntax for checking the file length has changed in
>> >> Simple language (or rather File language)? Looking at the documentation
>> I
>> >> can't see that I'm doing anything wrong.
>> >>
>> >> /Bengt
>> >>
>> >>
>> >> 2013/8/14 Claus Ibsen <claus.ibsen@gmail.com>
>> >>
>> >>> See also the readLockMinLength option
>> >>>
>> >>> On Wed, Aug 14, 2013 at 4:26 PM, Bengt Rodehav <bengt@rodehav.com>
>> wrote:
>> >>> > I have recently upgraded Camel to version 2.11.0. In my file transfer
>> >>> > services I have used a predicate together with interceptors to
avoid
>> >>> > transferring empty files but instead move them into a subfolder
>> called
>> >>> > "skipped". However, this has stopped working. My predicate looks
like
>> >>> this:
>> >>> >
>> >>> > *Predicate emptyFile =
>> >>> > PredicateBuilder.toPredicate(SimpleLanguage.simple("${file:length}
==
>> >>> 0"));
>> >>> > *
>> >>> >
>> >>> > I'm not exactly sure in what version this functionality broke but
I'm
>> >>> sure
>> >>> > it worked in version 2.7.1.
>> >>> >
>> >>> > Is there a better way to do this in Camel 2.11.0?
>> >>> >
>> >>> > /Bengt
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Claus Ibsen
>> >>> -----------------
>> >>> Red Hat, Inc.
>> >>> Email: cibsen@redhat.com
>> >>> Twitter: davsclaus
>> >>> Blog: http://davsclaus.com
>> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >>>
>> >>
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> Email: cibsen@redhat.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message