0

I have to do a query in db to get the filenames from a table. And then I have to read the contents of files in a folder/directory using the file names I got from query. I have done the query part and stored the list of filenames in Exchange using a bean. But I am wondering how can I use this filenames in exchange to read the file contents. Could you please help?

praveenps
  • 77
  • 1
  • 9

1 Answers1

3

You can use the pattern Content Enricher (http://camel.apache.org/content-enricher.html) and Camel 2.16 with dynamic endpoints to load the contents of a file, by path previously obtained from the database.

UPDATED

You have to use the pollEnrich (because file component is a polling consumer) to consume files from uri and you can use an expression (such as Simple) to configure the fileName.

You can try something like that (only for Camel version greater than 2.16):

.pollEnrich("file:?fileName=${header.FILE_NAME}", 1000, new YourAggregationStrategy()) 
Alexey Yakunin
  • 1,743
  • 1
  • 19
  • 21