| Author | Message | 
		
		  | Sam Uppu | 
			  
				|  Posted: Sat Aug 20, 2011 3:27 pm    Post subject: correlation id issue |   |  | 
		
		  |  Yatiri
 
 
 Joined: 11 Nov 2008Posts: 610
 
 
 | 
			  
				| Hi guys, 
 Based upon our requirement, I have to pass the correlation id of input message in payload. I have casted the correlationid field to char and assiged it to xml_correlid element of xml request and dropped to frontend application queue.
 
 The frontend application processes the message and will build xml response with the xml_correlid element  same as what is there in request.
 
 When the response arrives on the response flow of message broker, I casted the xml_correlid to BLOB and assigned it to OutputRoot.MQMD.CorrelID.
 
 When I saw the correlation ID in MQMD, i see it is not similar to the original one. The number of characters is also not same.
 
 I defined the xml_correlid element as string.
 
 
 Can you guy spls help on how to save the correlation id in request message and use it in response flow.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Sat Aug 20, 2011 4:26 pm    Post subject: Re: correlation id issue |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| Sam Uppu wrote: |  
	| I have casted the correlationid field to char |  
 It's not a character field. It's a byte array.
 
 
 
   
	| Sam Uppu wrote: |  
	| I defined the xml_correlid element as string. |  
 It's not a string either.
 
 
 
   
	| Sam Uppu wrote: |  
	| Can you guy spls help on how to save the correlation id in request message and use it in response flow. |  
 Store it as is in the XML (base64?)
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Sam Uppu | 
			  
				|  Posted: Sat Aug 20, 2011 6:26 pm    Post subject: Re: correlation id issue |   |  | 
		
		  |  Yatiri
 
 
 Joined: 11 Nov 2008Posts: 610
 
 
 | 
			  
				| 
   
	| Vitor wrote: |  
	| Store it as is in the XML (base64?)
 |  
 So, I need to store the correlationId as is in XML and later in response flow, I can  just retrieve and assign to OutputRoot.MQMD.CorrelId.
 
 I tried this yesterday and got some error saying MQMD cannot be char.
 
 Also what should be the datatype for xml element used?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | smdavies99 | 
			  
				|  Posted: Sat Aug 20, 2011 9:46 pm    Post subject: |   |  | 
		
		  |  Jedi Council
 
 
 Joined: 10 Feb 2003Posts: 6076
 Location: Somewhere over the Rainbow this side of Never-never land.
 
 | 
			  
				| As Vitor has said, the CorrelId (and MsgId and GroupId) are NOT human readable fields. They may look it but they are not. 
 If you doubt this, take a look at the way they are defined in the WMQ header file cmqc.h
 
 So the question remains as to how you can include them in an XML structure in a form that you can use later in an MQMD.
 
 Encode it as Base64 (in ESQL in V7.0.0.2) and then tag the XML field type as Base64Binary in your XSD.
 _________________
 WMQ User since 1999
 MQSI/WBI/WMB/'Thingy' User since 2002
 Linux user since 1995
 
 Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Sam Uppu | 
			  
				|  Posted: Sun Aug 21, 2011 4:36 pm    Post subject: |   |  | 
		
		  |  Yatiri
 
 
 Joined: 11 Nov 2008Posts: 610
 
 
 | 
			  
				| 
   
	| smdavies99 wrote: |  
	| Encode it as Base64 (in ESQL in V7.0.0.2) and then tag the XML field type as Base64Binary in your XSD.
 |  
 
 Vitor/samdavies99,
 
 Thank you. Will try the option suggested.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | lancelotlinc | 
			  
				|  Posted: Mon Aug 22, 2011 5:40 am    Post subject: |   |  | 
		
		  |  Jedi Knight
 
 
 Joined: 22 Mar 2010Posts: 4941
 Location: Bloomington, IL USA
 
 | 
			  
				| Sam -- look in source code from June 2010. You will find example of representing the CorrelId as a string. _________________
 http://leanpub.com/IIB_Tips_and_Tricks
 Save $20: Coupon Code: MQSERIES_READER
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Sam Uppu | 
			  
				|  Posted: Mon Aug 22, 2011 7:32 am    Post subject: |   |  | 
		
		  |  Yatiri
 
 
 Joined: 11 Nov 2008Posts: 610
 
 
 | 
			  
				| I am not with the same client. 
 Last edited by Sam Uppu on Mon Aug 22, 2011 7:39 am; edited 1 time in total
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Sam Uppu | 
			  
				|  Posted: Mon Aug 22, 2011 7:34 am    Post subject: |   |  | 
		
		  |  Yatiri
 
 
 Joined: 11 Nov 2008Posts: 610
 
 
 | 
			  
				| 
   
	| lancelotlinc wrote: |  
	| Sam -- look in source code from June 2010. You will find example of representing the CorrelId as a string. |  
 Hey,
 I am not with the same client.
 
 Thanks
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | lancelotlinc | 
			  
				|  Posted: Mon Aug 22, 2011 8:01 am    Post subject: |   |  | 
		
		  |  Jedi Knight
 
 
 Joined: 22 Mar 2010Posts: 4941
 Location: Bloomington, IL USA
 
 | 
			  
				| 
   
	| Code: |  
	| String refCorrelId = new String(); 
 for( int i = 0; i < 24; i++ ){
 
 String iHexStr = Integer.toHexString( msg.correlationId[i] );
 if ( iHexStr.length()>2 ) iHexStr = iHexStr.substring( iHexStr.length()-2 );
 if ( iHexStr.length()<2 ) refCorrelId = refCorrelId + "0";
 refCorrelId = refCorrelId + iHexStr;
 
 }
 |  _________________
 http://leanpub.com/IIB_Tips_and_Tricks
 Save $20: Coupon Code: MQSERIES_READER
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Mon Aug 22, 2011 8:05 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| 
   
	| lancelotlinc wrote: |  
	| 
   
	| Code: |  
	| String refCorrelId = new String(); 
 for( int i = 0; i < 24; i++ ){
 
 String iHexStr = Integer.toHexString( msg.correlationId[i] );
 if ( iHexStr.length()>2 ) iHexStr = iHexStr.substring( iHexStr.length()-2 );
 if ( iHexStr.length()<2 ) refCorrelId = refCorrelId + "0";
 refCorrelId = refCorrelId + iHexStr;
 
 }
 |  |  
 of course, in ESQL, this is just CAST(InputRoot.MQMD.CorrelId AS STRING).
 
 And then a bit of substringing to remove the X' and ' that wrap it.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | lancelotlinc | 
			  
				|  Posted: Mon Aug 22, 2011 11:58 am    Post subject: |   |  | 
		
		  |  Jedi Knight
 
 
 Joined: 22 Mar 2010Posts: 4941
 Location: Bloomington, IL USA
 
 | 
			  
				| Definately the ESQL use case is much more efficient from a programmatic perspective, unless you want to use log4j to record the CorrelId. _________________
 http://leanpub.com/IIB_Tips_and_Tricks
 Save $20: Coupon Code: MQSERIES_READER
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Mon Aug 22, 2011 12:02 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| lancelotlinc wrote: |  
	| unless you want to use log4j to record the CorrelId. |  
 Which the OP has given no indication of, intending it seems to use it to correlate a response.
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Sam Uppu | 
			  
				|  Posted: Mon Aug 22, 2011 7:03 pm    Post subject: |   |  | 
		
		  |  Yatiri
 
 
 Joined: 11 Nov 2008Posts: 610
 
 
 | 
			  
				| Hi All, 
 Thanks for all your suggestions.
 
 I used base64 encoding as suggested and it worked.
 
 Thanks
 Sam
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |