You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by roger_rabbit <ro...@gmx.fr> on 2013/07/26 16:42:26 UTC
Using {date:..} placeholder in camel-context endpoint
Hi,
I am wondering whether it is possible to use a ${date:now:yyyyMMdd} on an
endpoint in my camel context file, in order to specify a date-related
endpoint (my endpoint will change everyday according to date).
I tried something such as :
<endpoint id="com.my.dir.out"
uri="file:${com.my.params.dir.out}/${date:now:yyyyMMdd}?autoCreate=true" />
but this didn't work : the first parameter "/com.my.params.dir.out/" was
parsed, but the date was instead replaced by "now:yyyyMMdd" (I also tried
something stupid such as : ${date:${date:now:yyyyMMdd}}, but this lead to
same result, indeed...):
/Cannot poll as directory does not
exists or its not a directory:
d:\tmp\camel\out\now:yyyyMMdd/
Is there anyway to use the date that way in context-file?
For information, my route are defined in a RouteBuilder class, and not in
the camel-context file.
Thanks in advance!
--
View this message in context: http://camel.465427.n5.nabble.com/Using-date-placeholder-in-camel-context-endpoint-tp5736295.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Using {date:..} placeholder in camel-context endpoint
Posted by roger_rabbit <ro...@gmx.fr>.
Thank you Claus,
this worked.
Eventually, I ended up changing the whole thing... because I read somewhere
<http://camel.465427.n5.nabble.com/read-all-files-in-folder-td4474104.html#a4478126>
that
"not every possible use case is a perfect fit in camel"* :)
Thus, I will have other problems... but that one is no more!
Thanks again for your kind help.
* : this should be sticked, cause this sentence really often makes sense!
--
View this message in context: http://camel.465427.n5.nabble.com/Using-date-placeholder-in-camel-context-endpoint-tp5736295p5736468.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Using {date:..} placeholder in camel-context endpoint
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yeah use baseFolder as the starting directory. And then use
/${date:now:yyyyMMdd} as prefix for the the file name.
....?fileName=${date:now:yyyyMMdd}/${file:name}
For the name of the file you can use the file language (part of simple
language), see
http://camel.apache.org/file-language.html
There is some examples here
http://camel.apache.org/file-language.html
On Mon, Jul 29, 2013 at 10:17 AM, roger_rabbit <ro...@gmx.fr> wrote:
> Thank you for your answer.
>
> I understand I can use a custom filter to filter directory based including
> the date I want to process, but not sure it is suited for creating a
> directory with such rule :
> => "write to a directory named /tmp/${yyyyMMdd} and create it if it does not
> exist".
>
> For the moment, I also tried creating the endpoint in my Route Builder :
>
> this.folderOut = "file:"+
> baseFolder+
> "/${date:now:yyyyMMdd}?autocreate=true";
>
> But I got an exception saying :
> /Dynamic expressions with ${ } placeholders is not allowed. Use the fileName
> option to set the dynamic expression./
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Using-date-placeholder-in-camel-context-endpoint-tp5736295p5736403.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
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
Re: Using {date:..} placeholder in camel-context endpoint
Posted by roger_rabbit <ro...@gmx.fr>.
Thank you for your answer.
I understand I can use a custom filter to filter directory based including
the date I want to process, but not sure it is suited for creating a
directory with such rule :
=> "write to a directory named /tmp/${yyyyMMdd} and create it if it does not
exist".
For the moment, I also tried creating the endpoint in my Route Builder :
this.folderOut = "file:"+
baseFolder+
"/${date:now:yyyyMMdd}?autocreate=true";
But I got an exception saying :
/Dynamic expressions with ${ } placeholders is not allowed. Use the fileName
option to set the dynamic expression./
--
View this message in context: http://camel.465427.n5.nabble.com/Using-date-placeholder-in-camel-context-endpoint-tp5736295p5736403.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Using {date:..} placeholder in camel-context endpoint
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You can use a filter on the file endpoint to filter the directory and
file names you want.
On Fri, Jul 26, 2013 at 4:42 PM, roger_rabbit <ro...@gmx.fr> wrote:
> Hi,
>
> I am wondering whether it is possible to use a ${date:now:yyyyMMdd} on an
> endpoint in my camel context file, in order to specify a date-related
> endpoint (my endpoint will change everyday according to date).
>
> I tried something such as :
> <endpoint id="com.my.dir.out"
> uri="file:${com.my.params.dir.out}/${date:now:yyyyMMdd}?autoCreate=true" />
>
> but this didn't work : the first parameter "/com.my.params.dir.out/" was
> parsed, but the date was instead replaced by "now:yyyyMMdd" (I also tried
> something stupid such as : ${date:${date:now:yyyyMMdd}}, but this lead to
> same result, indeed...):
>
> /Cannot poll as directory does not
> exists or its not a directory:
> d:\tmp\camel\out\now:yyyyMMdd/
>
> Is there anyway to use the date that way in context-file?
>
> For information, my route are defined in a RouteBuilder class, and not in
> the camel-context file.
>
> Thanks in advance!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Using-date-placeholder-in-camel-context-endpoint-tp5736295.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
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