On Fri, May 17, 2013 at 1:03 PM, Peter Hilton <pedro+ca...@lunatech.com> wrote:
> On 17 May 2013, at 09:33, Claus Ibsen <claus.ib...@gmail.com> wrote:
>> You can use the move option on the Camel file consumer, and then use a
>> bean to calculate the file name. http://camel.apache.org/file2
>
> Claus, by the way, your comment let to an 'aha' moment - the kind that 
> Manning talk about :)
>
> Being new to Camel, I hadn't realised the implications of the documentation 
> for File Component’s 'move' property (the implication being that I can write 
> my own code to calculate the file name):
>
>> move: Expression (such as File Language) used to dynamically set the 
>> filename when moving it after processing.
>
> Note that a later sentence on the same page seems to contract that I can use 
> this to calculate the file name:
>
>> The move and preMove options should be a directory name, which can be either 
>> relative or absolute.
>

Ah yeah let me update the docs to make this more clear. Thanks for
spotting this.


>
> Anyway, your suggestion to use a bean prompted me to drill down (→ 
> http://camel.apache.org/expressionhttp://camel.apache.org/bean-language) 
> and realise that I can always implement an expression or predicate as a 
> method in my own bean class.
>

Yes any expression / predicate can just be a method on a bean. For the
predicate the returned value is evaluated as a boolean or a non empty
value will be considered true.

> For what it’s worth, I don’t yet see how I would discover that my bean must 
> have a 'calculateFileName' method - whether Camel will pick this method 
> because it's the only one, or whether it has to have that name, for example. 
> I’ll save that for another day.
>

Yeah if there is only one method then that's picked up. You can also
tell Camel the name of the method to use

move=bean:myBean.myMethod

The bean selection logic is covered in CiA book chapter 4, or you can
find some details on the camel bean wiki pages, somewhere.

> Thanks again,
> Peter
>



--
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cib...@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to