| Author | Message | 
		
		  | mjain_mq | 
			  
				|  Posted: Sun Jul 14, 2013 11:30 pm    Post subject: MQMessage Correlation ID getting changed |   |  | 
		
		  | Newbie
 
 
 Joined: 14 Jul 2013Posts: 6
 
 
 | 
			  
				| Hi, I have a java adapter which reads message off the queue. I am trying to access the correlation id as I need same to be logged. When I try to read the Correlation ID and convert it into string, it somehow changes the value. I think it might be because its getting converted into ASCII equivalent. Below if the piece of code. Could anyone please suggest how can I get the correlation id into string. Thanks
 
 
   
	| Code: |  
	| 
 byte[] msgIdBytes = message.correlationId;
 StringBuffer msgID = new StringBuffer();
 for (int i = 0; i < msgIdBytes.length; i++) {
 msgID.append(msgIdBytes[i]);
 }
 String strMsgID = msgID.toString();
 
 |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | exerk | 
			  
				|  Posted: Sun Jul 14, 2013 11:51 pm    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 02 Nov 2006Posts: 6339
 
 
 | 
			  
				| The CORRELID is specified as MQBYTE24, and is usually the value of the MSGID (in request/reply scenarios) so why do you want to convert it to string? _________________
 It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mjain_mq | 
			  
				|  Posted: Mon Jul 15, 2013 12:25 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 14 Jul 2013Posts: 6
 
 
 | 
			  
				| Thanks for reply exerk.....I need to pass the Correl id to another application which logs it and same is used as transaction is to identify the transactions. Is there any way we can read correlation id or Msg id as string? |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | exerk | 
			  
				|  Posted: Mon Jul 15, 2013 12:29 am    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 02 Nov 2006Posts: 6339
 
 
 | 
			  
				| 
   
	| mjain_mq wrote: |  
	| Thanks for reply exerk.....I need to pass the Correl id to another application which logs it and same is used as transaction is to identify the transactions. Is there any way we can read correlation id or Msg id as string? |  Again, why do you want it as a string?
 _________________
 It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mjain_mq | 
			  
				|  Posted: Mon Jul 15, 2013 12:33 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 14 Jul 2013Posts: 6
 
 
 | 
			  
				| Ok.....There is another application called TEX. Now TEX uses the transaction ids to update the state of transaction. When client puts message to the queue, it records the transaction (using the Msg id as identifier) in TEX. Now, when ny adapter reads the message off the queue, it needs to update the transaction in TEX using the same identifier, which is Msg Id or Correl Id. So I need to convert the Correl id/Msg Id into string and pass it to TEX so that it can update the transaction. This is the design we have running for long time. Its just that I am not able to pass the Msg id as string without getting ita value changed. Thanks |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | exerk | 
			  
				|  Posted: Mon Jul 15, 2013 12:35 am    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 02 Nov 2006Posts: 6339
 
 
 | 
			  
				| 
   
	| mjain_mq wrote: |  
	| Ok.....There is another application called TEX. Now TEX uses the transaction ids to update the state of transaction. When client puts message to the queue, it records the transaction (using the Msg id as identifier) in TEX. Now, when ny adapter reads the message off the queue, it needs to update the transaction in TEX using the same identifier, which is Msg Id or Correl Id. So I need to convert the Correl id/Msg Id into string and pass it to TEX so that it can update the transaction. This is the design we have running for long time. Its just that I am not able to pass the Msg id as string without getting ita value changed. Thanks |  Does TEX require the CORRELID value be a string, or can it just accept the value passed to it?
 _________________
 It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Mon Jul 15, 2013 12:49 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| An MQMD.CorrelationID or MQMD.MessageId field is, as mentioned, a 24 byte long field. 
 MQ always treats these fields as bytes.
 
 These bytes can happily represent a 24 character ASCII string.  They can happily represent a no-more-than-24-character UNICODE string (unicode being a multibyte character set)
 
 If you allow MQ to generate either of these IDs, they will be byte strings that do not necessarily represent valid character strings.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mjain_mq | 
			  
				|  Posted: Mon Jul 15, 2013 12:52 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 14 Jul 2013Posts: 6
 
 
 | 
			  
				| 
   
	| Quote: |  
	| Does TEX require the CORRELID value be a string, or can it just accept the value passed to it?
 
 |  
 TEX needs it as a string. It actually expects an XML message with transaction id as one of the tags. I need to pass the correl id in this tag.
 Thanks
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mjain_mq | 
			  
				|  Posted: Mon Jul 15, 2013 1:01 am    Post subject: |   |  | 
		
		  | Newbie
 
 
 Joined: 14 Jul 2013Posts: 6
 
 
 | 
			  
				| Thanks mqjeff.......could you please suggest the way to get the correl id into string. |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Mon Jul 15, 2013 1:03 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| it's reasonably common to treat the 24 bytes of a message id or correlation id as a 48 byte character string, where each character represents a hexadecimal encoding of half the byte. 
 Without taking some step to create a known mapping between 24 bytes and some character string, you have to accept that some of your string may be handled badly.
 
 In particular, putting an MQ Message ID into an xml document without performing a translation could cause the XMl document to be come invalid and unparsable.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Michael Dag | 
			  
				|  Posted: Mon Jul 15, 2013 2:39 am    Post subject: |   |  | 
		
		  |  Jedi Knight
 
 
 Joined: 13 Jun 2002Posts: 2607
 Location: The Netherlands (Amsterdam)
 
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |