You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Andy Fedotov (JIRA)" <ji...@apache.org> on 2015/07/10 21:22:05 UTC

[jira] [Commented] (CAMEL-4596) enrich and pollEnrich should accept an expression for dynamic uris

    [ https://issues.apache.org/jira/browse/CAMEL-4596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14622791#comment-14622791 ] 

Andy Fedotov commented on CAMEL-4596:
-------------------------------------

This is must-have feature, I hope it will be implemented ASAP and as it should.
Meanwhile it can be implemented with custom message Processor. I've created and using one.

https://gist.github.com/afedotov/c9565ac5a53a45662d30

Example:
{code:java}
String enrichURI = "file:path/to/basedir/${date:now:yyyyMMdd}?fileName=index.xml";
 
from("direct:start")
    .process(DynamicPollEnricher.from(simple(enrichURI)))
    .to("bean:messageProcessor")
    .to("mock:result");
{code}

More example:
- Scan directory recursively for *.pdf files and read each one
- Enrich it with .xml file that located next to .pdf file and has same name
- Pass two files together for processing

{code:java}
String startURI = "file:path/to/docs?recursive=true&antInclude=**/*.pdf&noop=true&readLock=none";
String enrichURI = "file:${header.CamelFileParent}?fileName=${file:onlyname.noext}.xml&noop=true&readLock=none";

from(startURI)
    .process(DynamicPollEnricher.from(simple(enrichURI)))
    .to("bean:processDocument")
    .to("mock:result");
{code}

For accessing message list body inside processor beans there are helper methods:
{code:java}
InputStream pdfFileStream = DynamicPollEnricher.getMessageBody(inputExchange, 0, InputStream.class);
Document metadata = DynamicPollEnricher.getMessageBody(inputExchange, 1, Document.class);
{code}

> enrich and pollEnrich should accept an expression for dynamic uris
> ------------------------------------------------------------------
>
>                 Key: CAMEL-4596
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4596
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Priority: Minor
>             Fix For: 3.0.0
>
>
> We should consider using an expression for uri's for the enrich and pollEnrich EIP's so we can poll from a dynamic computed endpoint.
> However it will break API as currently the uri is mandatory.
> It's a bit the same problem with to EIP which is also static uri. However for to EIP we have recipientList which is the dynamic to.
> So we need a similar dynamic for enrich and pollEnrich. 
> This also solves the problem with that people wan't to provide details from the current exchange in the endpoint uri. We have a ticket for that.
> eg enrich("file:inbox?fileName=${header.nameToPickUp}")
> So if we can do it using an expression it could be
> .enrich().simple("file:inbox?fileName=${header.nameToPickUp}")
> See nabble
> http://camel.465427.n5.nabble.com/pollEnrich-consumer-with-selector-tp4939908p4939908.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)