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

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

问题描述

我必须在 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 (http://camel.apache.org/content-enricher.html) 和 Camel 2.16 使用动态端点加载文件的内容,通过之前从数据库.

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 组件是一个 轮询使用者)来使用来自 uri 的文件,并且您可以使用表达式(如 Simple)配置文件名.

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 的 Camel 版本):

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天全站免登陆