Reading file content using file name from db in camel

半世苍凉 提交于 2019-12-11 14:40:00

问题


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?


回答1:


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()) 


来源:https://stackoverflow.com/questions/45282089/reading-file-content-using-file-name-from-db-in-camel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!