在 Camel DSL“to"中使用 Exchange 属性

编程入门 行业动态 更新时间:2024-10-28 10:27:55
本文介绍了在 Camel DSL“to"中使用 Exchange 属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我想在 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/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/manual/latest/faq/how-to-use-a-dynamic-uri-in-to.html

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

更多推荐

[db:关键词]

本文发布于:2023-04-19 22:09:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/971509.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   DSL   Camel   Exchange   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!