在 Camel DSL“to"中使用 Exchange 属性 [英] Use Exchange Property in Camel DSL "to"

查看:30
本文介绍了在 Camel DSL“to"中使用 Exchange 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Camel Exchange 上设置一个属性,然后在保存文件时使用该属性.在我的骆驼 dsl 中,我有以下内容:

I want to set a property on a Camel Exchange and then use this property when saving the file. In my camel dsl I have the following:

.process(processorToSetExhangeProperty)  // sets the property <uid> on the exchange
.to("file:/tmp?fileName=file-" + property("uid") + ".xml")

文件被保存为:

"file-property{uid}.xml" though

我的处理器如下:

@Override
public void process(Exchange exchange) throws Exception {
    UUID uuid = UUID.randomUUID();
    exchange.setProperty("uid", uuid.toString());
    exchange.setOut(exchange.getIn());
}

对可能出现的问题或我如何实现这一目标有任何想法吗?

Any thoughts on what may be going wrong or how I can achieve this?

推荐答案

Camel 中的 to 在运行时不被解释.

The to in the Camel is not interpreted at runtime.

如果您想动态构建您的 URI,您应该使用收件人列表.请参阅 https://camel.apache.org/manual/latest/faq/how-to-use-a-dynamic-uri-in-to.html

You should use recipientList if you want to construct your URI dynamically. See https://camel.apache.org/manual/latest/faq/how-to-use-a-dynamic-uri-in-to.html

这篇关于在 Camel DSL“to"中使用 Exchange 属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆