简体   繁体   English

交换消息头格式

[英]Exchange message Header formatting

I am trying to set exchange message header.我正在尝试设置交换消息头。 I need Help In formatting the code.我需要帮助格式化代码。 I need to set below values in header我需要在标题中设置以下值

usr.Person.Name = "Peter"
usr.Person.ID = "ABC123"

I tried我试过

exchange.getIn().setHeader("usr.Person.Name", "Peter");
exchange.getIn().setHeader("usr.Person.ID", "ABC123");

But when I see in Active MQ it is formatted as但是当我在 Active MQ 中看到它的格式为

usr_DOT_Person_DOT_Name: Peter
usr_DOT_Person_DOT_ID : ABC123

I need to print as it is, I tried to google is but no luck.我需要按原样打印,我试过谷歌是但没有运气。 Any suggestions??有什么建议??

It's a violation of the JMS specification to use a .使用. character in the name of a message header/property which is why the Camel JMS component translates it to DOT as noted in the documentation .消息头/属性名称中的字符,这就是 Camel JMS 组件将其转换为DOT文档所述 You can always translate it back into the original format when you read it.阅读时,您可以随时将其翻译回原始格式。

From Camel in action从骆驼在行动

In Camel, a header can be named anything that will fit in a Java String, and its value can be any Java object.在 Camel 中,标题可以命名为任何适合 Java 字符串的名称,其值可以是任何 Java 对象。 This presents a few problems when sending to and receiving from JMS destinations.这在向 JMS 目的地发送和接收时会出现一些问题。

... Any period (.) characters are replaced by DOT , and any hyphens (-) are replaced with HYPHEN . ... 任何句点 (.) 字符都替换为DOT ,任何连字符 (-) 替换为HYPHEN For example, a header named org.apache.camel.Test-Header would be converted to org_DOT_apache_DOT_camel_DOT_Test_HYPHEN_Header before being sent to a JMS destination.例如,名为 org.apache.camel.Test-Header 的标头将在发送到 JMS 目标之前转换为 org_DOT_apache_DOT_camel_DOT_Test_HYPHEN_Header。 If this message is consumed by a Camel route at some point down the line, the header name will be converted back.如果此消息在线路下游的某个点被 Camel 路由消耗,则标头名称将被转换回。

Also you can find this info here https://camel.apache.org/components/latest/jms-component.html in MESSAGE HEADER MAPPING section.您也可以在https://camel.apache.org/components/latest/jms-component.html的 MESSAGE HEADER MAPPING 部分找到此信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM