我想在 Camel Exchange 上设置一个属性,然后在保存文件时使用这个属性。在我的骆驼 dsl 中,我有以下内容:
.process(processorToSetExhangeProperty) // sets the property <uid> on the exchange
.to("file:/tmp?fileName=file-" + property("uid") + ".xml")
Run Code Online (Sandbox Code Playgroud)
该文件被保存为:
"file-property{uid}.xml" though
Run Code Online (Sandbox Code Playgroud)
我的处理器如下:
@Override
public void process(Exchange exchange) throws Exception {
UUID uuid = UUID.randomUUID();
exchange.setProperty("uid", uuid.toString());
exchange.setOut(exchange.getIn());
}
Run Code Online (Sandbox Code Playgroud)
关于可能出了什么问题或我如何实现这一目标的任何想法?
小智 4
Camel 中的to不会在运行时解释。
如果您想动态构建您的 URI,您应该使用recipientList。请参阅https://camel.apache.org/manual/latest/faq/how-to-use-a-dynamic-uri-in-to.html