Apache Camel-如何在动态SFTP端点中设置私钥 [英] Apache Camel - How to set a private key in a dinamic sftp endpoint
问题描述
使用Java DSL,我有一条路由,可以使用消息头中设置的文件名来轮询SFTP服务器中的文件
Using Java DSL, I have a route in which I poll a file in an SFTP server using the file name set in the message headers
from("direct:download")
.pollEnrich()
.simple("sftp://my.host:22/folder/?username=foo&fileName=${header.CamelFileName}")
.to("file://state/downloaded");
sftp端点需要设置一个私钥.通常这样的话就足够了:
The sftp endpoint needs to have set a private key. Usually something like this suffices:
endpoint("sftp://my.host:22/folder/?username=foo&fileName=my_file_explicitly_written_here", SftpEndpoint.class).getConfiguration().setPrivateKey(getSshPrivateKey());
但是,我看不到将pollEnrich().simple()
中URI(${header.CamelFileName}
)中的动态字段与端点配置混合"的方法.
However, I see no way to "mix" dynamic fields in the URI (${header.CamelFileName}
) in the pollEnrich().simple()
) with endpoint configuration.
对此有何建议?
推荐答案
您可以从注册表中引用privateKey
作为bean.
You can reference privateKey
as bean from registry.
.pollEnrich()
.simple("sftp://my.host:22/folder/?username=foo&privateKey=#myKeyInRegistry&fileName=${header.CamelFileName}")
将bean绑定到注册表取决于您使用的平台和Camel版本.
Binding bean to registry depends on platform and Camel version you are using.
这篇关于Apache Camel-如何在动态SFTP端点中设置私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!