Error in wiki about pollEnrich?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Error in wiki about pollEnrich?

Andreas A.
Hi

I have a use case as this:
1. read an xml file
2. extract a file name from the xml file
3. poll for the extracted filename

As I believe the easiest way to do this is with Enricher I came across the example in the bottom of http://camel.apache.org/content-enricher.html.

The red box says:
"For example you cannot set a filename in the Exchange.FILE_NAME header and use pollEnrich to consume only that file. For that you must set the filename in the endpoint URI."

But the sample tries exactly that?
from("activemq:queue:order")
   .setHeader(Exchange.FILE_NAME, header("orderId"))
   .pollEnrich("file://order/data/additional")
   .to("bean:processOrder");
Reply | Threaded
Open this post in threaded view
|

Re: Error in wiki about pollEnrich?

Andreas A.
And for the record nothing seems to work when using dynamic file names:

This works:
<route>
        <from uri="file:test_data/in?move=../../done&amp;delay=10s" />
        <to uri="seda:in" />
</route>
 <route>
        <from uri="seda:in" />
        <pollEnrich uri="file:test_data/enrich?fileName=enrich2.txt" />
        <to uri="file:test_data/out?fileName=out.txt" />
</route>

These don't:

<route>
        <from uri="file:test_data/in?move=../../done&amp;delay=10s" />
        <to uri="seda:in" />
</route>
<route>
        <from uri="seda:in" />
        <setHeader headerName="servicefile">
                <simple>enrich2.txt</simple>
        </setHeader>
        <pollEnrich uri="file:test_data/enrich?fileName=${in.header.filename}" />
        <to uri="file:test_data/out?fileName=out.txt" />
</route>
--------------
<route>
        <from uri="file:test_data/in?move=../../done&amp;delay=10s" />
        <to uri="seda:in" />
</route>
<route>
        <from uri="seda:in" />
        <setHeader headerName="CamelFileName">
                <simple>enrich2.txt</simple>
        </setHeader>
        <pollEnrich uri="file:test_data/enrich" />
        <to uri="file:test_data/out?fileName=out.txt" />
</route>

As the wiki is a bit ambiguous I'm not sure what is supposed to work and what isn't
Reply | Threaded
Open this post in threaded view
|

Re: Error in wiki about pollEnrich?

Andreas A.
Maybe this example in the old FTP page: http://camel.apache.org/ftp.html#FTP-ConsumingaremoteFTPservertriggeredbyaroute is the only way to achieve this at the moment?
Reply | Threaded
Open this post in threaded view
|

Re: Error in wiki about pollEnrich?

Claus Ibsen-2
In reply to this post by Andreas A.
Hi

Enrich cannot use any information from the current Exchange.
It's due to how the PollingConsumer API is designed.

There is a JIRA ticket to improve this in the future.

You can use a recipient list and construct a dynamic uri with the file
name you want to poll. And you can then provide an aggregration
strategy. For example the UseLatestAggregationStrategy.

You can also just use a pojo and get the file using a producer
template or by yourself.



On Wed, Aug 4, 2010 at 1:55 PM, Andreas Asmuss <[hidden email]> wrote:

>
> Hi
>
> I have a use case as this:
> 1. read an xml file
> 2. extract a file name from the xml file
> 3. poll for the extracted filename
>
> As I believe the easiest way to do this is with Enricher I came across the
> example in the bottom of http://camel.apache.org/content-enricher.html.
>
> The red box says:
> "For example you cannot set a filename in the Exchange.FILE_NAME header and
> use pollEnrich to consume only that file. For that you must set the filename
> in the endpoint URI."
>
> But the sample tries exactly that?
> from("activemq:queue:order")
>   .setHeader(Exchange.FILE_NAME, header("orderId"))
>   .pollEnrich("file://order/data/additional")
>   .to("bean:processOrder");
> --
> View this message in context: http://camel.465427.n5.nabble.com/Error-in-wiki-about-pollEnrich-tp2263967p2263967.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: Error in wiki about pollEnrich?

Andreas A.
Ah ok.

What are the samples in the wiki supposed to demonstrate then?
Reply | Threaded
Open this post in threaded view
|

Re: Error in wiki about pollEnrich?

Claus Ibsen-2
On Wed, Aug 4, 2010 at 2:39 PM, Andreas Asmuss <[hidden email]> wrote:
>
> Ah ok.
>
> What are the samples in the wiki supposed to demonstrate then?
> --

There is still a lot you can enrich so the wiki examples are fine.



> View this message in context: http://camel.465427.n5.nabble.com/Error-in-wiki-about-pollEnrich-tp2263967p2264015.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: Error in wiki about pollEnrich?

Claus Ibsen-2
On Wed, Aug 4, 2010 at 2:42 PM, Claus Ibsen <[hidden email]> wrote:
> On Wed, Aug 4, 2010 at 2:39 PM, Andreas Asmuss <[hidden email]> wrote:
>>
>> Ah ok.
>>
>> What are the samples in the wiki supposed to demonstrate then?
>> --
>
> There is still a lot you can enrich so the wiki examples are fine.
>

Ah the bottom examples was wrong. I have fixed them.
They will work when we make it possible for PollingConsumer to access
data from current Exchange.


>
>
>> View this message in context: http://camel.465427.n5.nabble.com/Error-in-wiki-about-pollEnrich-tp2263967p2264015.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



--
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Reply | Threaded
Open this post in threaded view
|

Re: Error in wiki about pollEnrich?

Andreas A.
In reply to this post by Claus Ibsen-2
Hi Claus

"You can use a recipient list and construct a dynamic uri with the file
name you want to poll. And you can then provide an aggregration
strategy. For example the UseLatestAggregationStrategy. "

Can you elaborate on how this is done. I can't quite put the pieces together to create what I need to do. That is, enrich with a specific filename from ftp.