You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by geppo <ge...@gmail.com> on 2017/05/08 12:20:11 UTC

Dynamic "from" and pollEnrich

I have a route with files (filename_YYYYMMDD.txt) as input endpoint i.e.

   from("file://folder/filename_*.txt")
      .transacted()
      .id("MyRoute")
      .process(new MyProcessor);

I want to trigger this route from a restful where the date part of the file
is specified in input i.e.

   template.sendBodyAndHeaders("direct:myRoute", null, "header:date",
"20170508")

so I've thought I could modify my route so that the input endpoint is
dynamic by using pollEnrich i.e.

   from("direct:myRoute")
      .transacted()
      .id("MyRoute")
      .pollEnrich().simple("file://folder/filename_${header:date}.txt")
      .process(new MyProcessor());

But nothing happens :(

If I had a timeout to pollEnrich then it waits for the milliseconds I
specified and then it runs MyProcessor regardless of the fact that the file
exists or not.

What am I doing wrong?
Thank you!



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-from-and-pollEnrich-tp5799032.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic "from" and pollEnrich

Posted by souciance <so...@gmail.com>.
And you are sure the file exist at that location with that name? I have
done pollEnrich with file before and that has worked.

Can you log the headers before the poll enrich and post it?

Den 8 maj 2017 4:47 em skrev "geppo [via Camel]" <
ml+s465427n5799112h35@n5.nabble.com>:

> Thanks souciance,
> yes I have header where I store the date, as per my original post:
>
> "I want to trigger this route from a restful where the date part of the
> file is specified in input i.e.
>
>    template.sendBodyAndHeaders("direct:myRoute", null, "header:date",
> "20170508")
> "
>
> I've tried ${headers.date} as well as ${header.date} as well as
> ${in.header.date} as well as ${in.headers.date}... no luck.
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Dynamic-from-and-
> pollEnrich-tp5799032p5799112.html
> To start a new topic under Camel - Users, email ml+s465427n465428h31@n5.
> nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-from-and-pollEnrich-tp5799032p5799120.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic "from" and pollEnrich

Posted by geppo <ge...@gmail.com>.
Thanks souciance,
yes I have header where I store the date, as per my original post:

"I want to trigger this route from a restful where the date part of the file
is specified in input i.e. 

   template.sendBodyAndHeaders("direct:myRoute", null, "header:date",
"20170508") 
"

I've tried ${headers.date} as well as ${header.date} as well as
${in.header.date} as well as ${in.headers.date}... no luck.



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-from-and-pollEnrich-tp5799032p5799112.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic "from" and pollEnrich

Posted by souciance <so...@gmail.com>.
One question,

Do you have a header where you store the date and you want to use that, or
do you want to access the simple language to access current date?

If I am not misstaken if it is the former, it should be ${headers.date} and
for the latter it should be ${date:now:yyyyMMdd} to include year, month and
date.

On Mon, May 8, 2017 at 4:04 PM, geppo [via Camel] <
ml+s465427n5799105h18@n5.nabble.com> wrote:

> Thank you Claus,
> if I understood right then my route should change like this:
>
>    from("direct:myRoute")
>        .transacted()
>        .id("MyRoute")
>        .pollEnrich().simple("file://folder?fileName=filename_${header:date}.txt")
>
>        .process(new MyProcessor())
>
> But nothing changed really.
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://camel.465427.n5.nabble.com/Dynamic-from-and-
> pollEnrich-tp5799032p5799105.html
> To start a new topic under Camel - Users, email ml+s465427n465428h31@n5.
> nabble.com
> To unsubscribe from Camel - Users, click here
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY=>
> .
> NAML
> <http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-from-and-pollEnrich-tp5799032p5799106.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic "from" and pollEnrich

Posted by geppo <ge...@gmail.com>.
Thank you Claus,
if I understood right then my route should change like this:

   from("direct:myRoute") 
       .transacted() 
       .id("MyRoute") 
      
.pollEnrich().simple("file://folder?fileName=filename_${header:date}.txt")
       .process(new MyProcessor())

But nothing changed really.



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-from-and-pollEnrich-tp5799032p5799105.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamic "from" and pollEnrich

Posted by Claus Ibsen <cl...@gmail.com>.
The file component is configured with the directory, and then you use
fileName=xxx to specify the file name. So separate these two.



On Mon, May 8, 2017 at 2:20 PM, geppo <ge...@gmail.com> wrote:
> I have a route with files (filename_YYYYMMDD.txt) as input endpoint i.e.
>
>    from("file://folder/filename_*.txt")
>       .transacted()
>       .id("MyRoute")
>       .process(new MyProcessor);
>
> I want to trigger this route from a restful where the date part of the file
> is specified in input i.e.
>
>    template.sendBodyAndHeaders("direct:myRoute", null, "header:date",
> "20170508")
>
> so I've thought I could modify my route so that the input endpoint is
> dynamic by using pollEnrich i.e.
>
>    from("direct:myRoute")
>       .transacted()
>       .id("MyRoute")
>       .pollEnrich().simple("file://folder/filename_${header:date}.txt")
>       .process(new MyProcessor());
>
> But nothing happens :(
>
> If I had a timeout to pollEnrich then it waits for the milliseconds I
> specified and then it runs MyProcessor regardless of the fact that the file
> exists or not.
>
> What am I doing wrong?
> Thank you!
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Dynamic-from-and-pollEnrich-tp5799032.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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