Pratik Shelar
Pratik Shelar

Reputation: 3212

JMS Correlation ID getting truncated

I am setting uuid field as JMSCorrelationID to my outbound message. I also set the reply to Queue and reply to Quemanger for getting COD. After setting correct user Identifier I am able to receive the COD message in the set ReplyTo Q. But the correlationID received in the COD message has truncated the bytes of my UUID field to 32 bytes. Due to this I cannot reconcile the message to which COD was received. Please find below code while sending the message. I have omitted the ReplyToQ and ReplytoQm part but it works as expected.

if(msgUuidId != null){
                    msg.setJMSCorrelationID(msgUuidId);
}
logger.info("Setting IBM_REPORT_COD");
msg.setIntProperty(JmsConstants.JMS_IBM_REPORT_COD, MQC.MQRO_COD);
logger.info("Setting JMS_IBM_MQMD_USERIDENTIFIER to :: "+ userid );
msg.setStringProperty(JmsConstants.JMS_IBM_MQMD_USERIDENTIFIER, userid);

I am also setting the MQMD Context on destination

((MQDestination) destination).setTargetClient(WMQConstants.WMQ_CLIENT_NONJMS_MQ);              
    ((JmsDestination) destination).setBooleanProperty(WMQConstants.WMQ_MQMD_READ_ENABLED, true);
    ((JmsDestination) destination).setBooleanProperty(WMQConstants.WMQ_MQMD_WRITE_ENABLED, true);    
    ((MQDestination) destination).setMQMDMessageContext(WMQConstants.WMQ_MDCTX_SET_IDENTITY_CONTEXT);

While receiving the message I am reading as follows:. I am using Mule API

String correlationID = (String)eventContext.getMessage().getInboundProperty("JMSCorrelationID");

So here I am observing that the value is truncated hex portion of uuid which I had set. Can someone please help me with this?

Upvotes: 1

Views: 3039

Answers (1)

Anders R. Bystrup
Anders R. Bystrup

Reputation: 16060

Shashi's comment rang a bell. As can be read here, MQ truncates JMSCorrelationId to 48 hex digits/24 bytes:

Note 1: The MQMD CorrelId field can hold a standard WebSphere MQ Correlation ID of 48 hexadecimal digits (24 bytes). The JMSCorrelationID can be a byte[] value, a string value containing hexadecimal characters and prefixed with "ID:", or an arbitrary string value not beginning "ID:". The first two of these represent a standard WebSphere MQ Correlation ID and map directly to or from the MQMD CorrelId field (truncated or padded with zeros as applicable); they do not use the MQRFH2 jms.Cid field. The third (arbitrary string) uses the MQRFH2 jms.Cid field; the first 24 bytes of the string, in UTF-8 format, are written into the MQMD CorrelID.

Does that correlate (pun intended) to the truncation you're seeing? If so, the pragmatic solution would be to use a 24 byte correlation ID.

Cheers,

Upvotes: 1

Related Questions