使用骆驼数据库中的文件名读取文件内容 [英] Reading file content using file name from db in camel

查看:67
本文介绍了使用骆驼数据库中的文件名读取文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在db中进行查询才能从表中获取文件名.然后,我必须使用从查询中获得的文件名来读取文件夹/目录中文件的内容.我已经完成了查询部分,并使用bean在Exchange中存储了文件名列表.但是我想知道如何使用此文件名来交换文件内容.你能帮忙吗?

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?

推荐答案

您可以使用 Content Enricher (

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.

已更新

您必须使用 pollEnrich (因为 file 组件是 polling使用者)来使用uri中的文件,并且可以使用表达式(例如Simple)来配置fileName.

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.

您可以尝试类似的操作(仅适用于2.16以上的骆驼版本):

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

.pollEnrich("file:?fileName=${header.FILE_NAME}", 1000, new YourAggregationStrategy()) 

这篇关于使用骆驼数据库中的文件名读取文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆