[英]Processing Camel message with Bean component
I have a Camel route with FTP and Bean component which processes the message. 我有一个使用FTP和Bean组件的骆驼路由来处理消息。 This message is a file on FTP and I would like to get the filename of each file processed.
此消息是FTP上的文件,我想获取每个已处理文件的文件名。 I know how to get files with parameter String, but then I cannot get the filename.
我知道如何使用参数String来获取文件,但是后来我无法获取文件名。 Thanks for the answer.
感谢您的回答。
The Camel FTP component extends the File component, the File Component adds the following headers when consuming a file: Camel FTP组件扩展了File组件,File组件在使用文件时添加了以下标头:
CamelFileName
: Name of the consumed file as a relative file path with offset from the starting directory configured on the endpoint. CamelFileName
:消耗的文件的名称,作为相对文件路径,相对于端点上配置的起始目录有偏移。 CamelFileNameOnly
: Only the file name (the name with no leading paths). CamelFileNameOnly
:仅文件名(无前导路径的名称)。 You can check out the other available headers in the "File consumer only" section of the File2 documentation page . 您可以在File2文档页面的“仅文件使用方”部分中检出其他可用的标头。
In a bean method, you can pass a specific header as a parameter using the @Simple
annotation giving it the value "header.<header name>"
. 在bean方法中,您可以使用
@Simple
批注将特定的标头作为参数@Simple
给它,并@Simple
提供值"header.<header name>"
。 For example: 例如:
public void processFile(@Body String fileContent, @Simple("header.CamelFileNameOnly") String fileName){
// your method implementation
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.