java - JMSCorrelationID 前缀为 ID :

标签 java jms

我有一些代码是这样做的:

String transactionId = incoming.getJMSCorrelationID();

当我使用 ActiveMQ 进行测试时,我能够毫无问题地发送消息并获取该值。但是,当我连接到 Websphere 时,该值以“ID:”为前缀,我不知道为什么会这样——中间件人员告诉我我的代码必须添加它——但事实并非如此。

删除它对我来说很简单,但我想知道为什么会出现这个前缀 - 任何人有什么想法吗?

最佳答案

我相信中间件人是错误的:

JMSMessageID from MQMD MessageID

All messages sent from JMS have unique message identifiers assigned by WebSphere® MQ. The value assigned is returned in the MQMD messageId field after the MQPUT call, and is passed back to the application in the JMSMessageID field. The WebSphere MQ messageId is a 24-byte binary value, whereas the JMSMessageID is a string. The JMSMessageID is composed of the binary messageId value converted to a sequence of 48 hexadecimal characters, prefixed with the characters ID:. JMS provides a hint that can be set to disable the production of message identifiers. This hint is ignored, and a unique identifier is assigned in all cases. Any value that is set into the JMSMessageId field before a send() is overwritten.

发件人:Mapping JMS header fields at send() or publish() .

此外,我还记得在使用 JMS-WebsphereMQ 桥时注意到该前缀。但实际上——你为什么要关心? 这是一个String id,规范没有说明它的结构,只是它必须是唯一的。

更新:实际上,如 @skaffman 所述,JMS specification 需要 ID: 前缀:

3.4.3. JMSMessageID

All JMSMessageID values must start with the prefix ‘ID:’. Uniqueness of message ID values across different providers is not required.

这意味着 WebsphereMQ 桥添加 ID: 前缀只是为了符合 JMS 规范。而且,正如 @skaffman 所指出的,ActiveMQ 不符合它...

关于java - JMSCorrelationID 前缀为 ID :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9564527/

相关文章:

java - Android 中任何线程中的异常为何以及如何导致整个应用程序崩溃

对象数组的Java Stream Reduce

jms - Apache Apollo : java openwire client doesn't consume messages from php stomp producer

php - JmsI18NBundle - 必须设置翻译所在的目录

java - 比较两个 XML 实例的变化

java - Netty 和 JavaFX 出现 "Not on FX application thread"异常

java - 使用 JGit 将存储库克隆到本地目录

java - JMS 中的重复持久订阅是什么

java - 如何从java异步发送soap消息

java - Java EE 中的异步执行