MQ 中的 JMS 关联 ID 不同

发布于 2025-01-20 00:09:18 字数 2432 浏览 1 评论 0原文

我正在编写一个 java spring boot 应用程序,它连接到 MQ、读取消息(由另一个应用程序放置)并向它们返回响应。

我正在尝试将相关 ID 设置为我们刚刚收到的消息 ID。

public void sendMessage(String destination, Item item, Message originalMessage) throws IOException {
    jmsTemplate.send(destinationName, session -> {

        Message message = createBytesMessage(item, session);

        message.setJMSCorrelationID(originalMessage.getJMSMessageID());

        log.info("Message: " + message);

        return message;
    });
}

原始消息 ID 是:

ID:414d5120514d44454c30315020202020f8af4d6202558722

回复消息具有预期的相关 ID:

ID:414d5120514d44454c30315020202020f8af4d6202558722

但是,当我调查 MQ 时,我可以看到相关 ID 实际上是:

343134643531323035313464343434353463333033313530

奇怪的是,如果我采用相关的预期值并将其转换为十六进制,我得到以下信息:

343134643531323035313464343434353463333033313530323032303230323066386166346436323032383338343232
// The first 48 characters match what is in MQ

这是来自 java 应用程序的调试信息:

这是原始消息:

JMSMessage class: jms_bytes
  JMSType:          null
  JMSDeliveryMode:  1
  JMSDeliveryDelay: 0
  JMSDeliveryTime:  0
  JMSExpiration:    0
  JMSPriority:      0
  JMSMessageID:     ID:414d5120514d44454c30315020202020f8af4d6202558722
  JMSTimestamp:     1649452421210
  JMSCorrelationID: null
  JMSDestination:   null
  JMSRedelivered:   false
    JMSXAppID: DataFlowEngine              
    JMSXDeliveryCount: 1
    JMSXUserID: mqm         
    JMS_IBM_Character_Set: UTF-8
    JMS_IBM_Encoding: 546
    JMS_IBM_Format:         
    JMS_IBM_MsgType: 1
    JMS_IBM_PutApplType: 6
    JMS_IBM_PutDate: 20220408
    JMS_IBM_PutTime: 21134121

这是出站消息的调试:

2022-04-08 22:13:42.020 DEBUG 31180 --- [enerContainer-1] o.springframework.jms.core.JmsTemplate   : Sending created message: 
  JMSMessage class: jms_bytes
  JMSType:          null
  JMSDeliveryMode:  2
  JMSDeliveryDelay: 0
  JMSDeliveryTime:  0
  JMSExpiration:    0
  JMSPriority:      4
  JMSMessageID:     null
  JMSTimestamp:     0
  JMSCorrelationID: ID:414d5120514d44454c30315020202020f8af4d6202558722
  JMSDestination:   null
  JMSReplyTo:       null
  JMSRedelivered:   false
7b22747261636b696e674964223a312c22737461747573223a2244454c495645524544222c226465
6c697665727944617465223a22323032322d30312d3031222c2274797065223a225345434f4e445f
434c415353227d

I'm writing a java spring boot app that connects to MQ, read messages (placed by another app) and returns a response to them.

I'm trying to set the correlation id to the message ID we've just received.

public void sendMessage(String destination, Item item, Message originalMessage) throws IOException {
    jmsTemplate.send(destinationName, session -> {

        Message message = createBytesMessage(item, session);

        message.setJMSCorrelationID(originalMessage.getJMSMessageID());

        log.info("Message: " + message);

        return message;
    });
}

The original message ID is:

ID:414d5120514d44454c30315020202020f8af4d6202558722

The reply message has a correlation ID as expected:

ID:414d5120514d44454c30315020202020f8af4d6202558722

However, when I investigate MQ I can see the correlation ID is actually:

343134643531323035313464343434353463333033313530

Curiously, if I take my expected value for the correlation and covert that to a hexdecimal, I get the following:

343134643531323035313464343434353463333033313530323032303230323066386166346436323032383338343232
// The first 48 characters match what is in MQ

Here is the debug information from the java application:

This is the original message:

JMSMessage class: jms_bytes
  JMSType:          null
  JMSDeliveryMode:  1
  JMSDeliveryDelay: 0
  JMSDeliveryTime:  0
  JMSExpiration:    0
  JMSPriority:      0
  JMSMessageID:     ID:414d5120514d44454c30315020202020f8af4d6202558722
  JMSTimestamp:     1649452421210
  JMSCorrelationID: null
  JMSDestination:   null
  JMSRedelivered:   false
    JMSXAppID: DataFlowEngine              
    JMSXDeliveryCount: 1
    JMSXUserID: mqm         
    JMS_IBM_Character_Set: UTF-8
    JMS_IBM_Encoding: 546
    JMS_IBM_Format:         
    JMS_IBM_MsgType: 1
    JMS_IBM_PutApplType: 6
    JMS_IBM_PutDate: 20220408
    JMS_IBM_PutTime: 21134121

This is the debug for the out bound message:

2022-04-08 22:13:42.020 DEBUG 31180 --- [enerContainer-1] o.springframework.jms.core.JmsTemplate   : Sending created message: 
  JMSMessage class: jms_bytes
  JMSType:          null
  JMSDeliveryMode:  2
  JMSDeliveryDelay: 0
  JMSDeliveryTime:  0
  JMSExpiration:    0
  JMSPriority:      4
  JMSMessageID:     null
  JMSTimestamp:     0
  JMSCorrelationID: ID:414d5120514d44454c30315020202020f8af4d6202558722
  JMSDestination:   null
  JMSReplyTo:       null
  JMSRedelivered:   false
7b22747261636b696e674964223a312c22737461747573223a2244454c495645524544222c226465
6c697665727944617465223a22323032322d30312d3031222c2274797065223a225345434f4e445f
434c415353227d

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文