On Tue, Mar 2, 2010 at 3:27 PM, ankelee <[email protected]> wrote:
>
> I have a message (text file) routed in one direction a that among other
> things holds an id. Then I have a bunch of text files in a directory, also
> with id's. I want to match the message with the text file that holds the
> corresponding id. I want to put those two files in a zip archive and store
> them in a directory.
>
> I'm thinking about using an aggregator or pollEnrich with a custom
> AggregationStrategy that takes a batch of 2, and checks whether the input
> has already been zipped, if yes then open ziparchive and add new entry, if
> not then create zip archive and add entry.
>
> The problem seems similar to Listing 3.3 in Camel In Action but how do I
> select with pollEnrich that I only want to consume one particular file
> depending on the id inside and leave the rest?
There is one limitation with pollEnrich, which is that it does not
support if the route is started from a file endpoint.
That kinda currently conflicts with the current codebase. There is a
JIRA ticket to enhance this in the future.
If you want to grab a file, then I suggest to use a Processor which
can easy do it like this
.process(new Processor()) {
public void process(Exchange exchange) throws Exception {
String filename = .... // you compute the file name to poll
File file = new File(filename);
// use the Camel type converters to load the file and return its
content as a String
String fileBody =
exchange.getContext().getTypeConverter().convertTo(String.class,
file);
// now you can merge that file body with the existing message on
Exchange.getIn().getBody
}
}.to("your route continues here")
> --
> View this message in context:
> http://old.nabble.com/Join-two-messages-from-two-sources-in-zip-archive.-tp27756477p27756477.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