使用 Bean 组件处理 Camel 消息
Processing Camel message with Bean component
我有一个带有 FTP 的 Camel 路由和处理消息的 Bean 组件。此消息是 FTP 上的一个文件,我想获取每个已处理文件的文件名。我知道如何使用参数 String 获取文件,但是我无法获取文件名。谢谢你的回答。
Camel FTP 组件扩展了文件组件,文件组件在使用文件时添加了以下 headers:
CamelFileName
:使用的文件的名称作为相对文件路径,与端点上配置的起始目录有偏移。
CamelFileNameOnly
:只有文件名(没有前导路径的名称)。
您可以在 File2 documentation page.
的 "File consumer only" 部分查看其他可用的 header
在 bean 方法中,您可以使用 @Simple
注释将特定的 header 作为参数传递,并为其赋予值 "header.<header name>"
。例如:
public void processFile(@Body String fileContent, @Simple("header.CamelFileNameOnly") String fileName){
// your method implementation
}
我有一个带有 FTP 的 Camel 路由和处理消息的 Bean 组件。此消息是 FTP 上的一个文件,我想获取每个已处理文件的文件名。我知道如何使用参数 String 获取文件,但是我无法获取文件名。谢谢你的回答。
Camel FTP 组件扩展了文件组件,文件组件在使用文件时添加了以下 headers:
CamelFileName
:使用的文件的名称作为相对文件路径,与端点上配置的起始目录有偏移。CamelFileNameOnly
:只有文件名(没有前导路径的名称)。
您可以在 File2 documentation page.
的 "File consumer only" 部分查看其他可用的 header在 bean 方法中,您可以使用 @Simple
注释将特定的 header 作为参数传递,并为其赋予值 "header.<header name>"
。例如:
public void processFile(@Body String fileContent, @Simple("header.CamelFileNameOnly") String fileName){
// your method implementation
}