Announcement Announcement Module
Collapse
No announcement yet.
setJMSMessageID not working in IBM MQ Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • setJMSMessageID not working in IBM MQ

    Hi,


    I'm trying to set the message id of JMS mesages directly as shown below:


    public void sendMessage( String replyTo,
    final String processedMessage,
    final String messageId) {
    jmsTemplate.send(replyTo, new MessageCreator() {
    public Message createMessage(Session session) throws JMSException {
    TextMessage message = session.createTextMessage();
    message.setText(processedMessage);
    message.setJMSMessageID(messageId);
    message.setJMSCorrelationID(messageId);
    return message;
    }

    }
    );
    }



    The snipppet above works properly for the correlation id, but not for message ID, I mean, the message id is not being set as expected. Also, I should mention that I'm working with IBM MQ.

    Please assist. Thanks.

  • #2
    Hi
    From looking at JMS javadoc it doesnt look like that property is settable in code by the sender:

    setJMSMessageID

    public void setJMSMessageID(String id)
    throws JMSException

    Sets the message ID.

    JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.
    Hence when you send the message I would guess that provider (IBM MQ) is setting the ID to its own generated value as specified in javadocs.

    Hope this helps
    /Tom

    Comment


    • #3
      JMSMessageID is read only in Websphere MQ

      Hello,

      JMSMessageID is read only in Websphere MQ JMS implementation.

      Extract from Websphere MQ Infocenter : Mapping JMS header fields at send() or publish()
      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.



      Other information about JMS to Websphere MQ headers mapping extracted from Websphere MQ Infocenter : Mapping JMS fields onto WebSphere MQ fields (outgoing messages)

      Outgoing message field mapping
      Code:
      | JMS header field | MQMD field used       | Header | Set by         |
      | name             | used for transmission |        |                |
      |                  |                       |        |                |
      | JMSDestination   |                       | MQRFH2 | Send Method    |
      | JMSDeliveryMode  | Persistence           | MQRFH2 | Send Method    |
      | JMSExpiration    | Expiry                | MQRFH2 | Send Method    |
      | JMSPriority      | Priority              | MQRFH2 | Send Method    |
      | JMSMessageID     | MessageID             |        | Send Method    |
      | JMSTimestamp     | PutDate/PutTime       |        | Send Method    |
      | JMSCorrelationID | CorrelId              | MQRFH2 | Message Object |
      | JMSReplyTo       | ReplyToQ/ReplyToQMgr  | MQRFH2 | Message Object |
      | JMSType          |                       | MQRFH2 | Message Object |
      | JMSRedelivered   |                       |        | Receive-only   |
      Outgoing message JMS property mapping

      Code:
      | JMS property name | MQMD field used  | Header | Set by         |
      |                   | for transmission |        |                |
      |                   |                  |        |                |
      | JMSXUserID        | UserIdentifier   |        | Send Method    |
      | JMSXAppID         | PutApplName      |        | Send Method    |
      | JMSXDeliveryCount |                  |        | Receive-only   |
      | JMSXGroupID       | GroupId          | MQRFH2 | Message Object |
      | JMSXGroupSeq      | MsgSeqNumber     | MQRFH2 | Message Object |
      Hope this helps,

      Cyrille

      Comment

      Working...
      X