Author |
Message
|
kirank |
Posted: Tue Apr 04, 2006 1:50 pm Post subject: Route based on CorrelId |
|
|
 Centurion
Joined: 10 Oct 2002 Posts: 136 Location: California
|
Hi,
I want to route messages based on Correlation Id. I have following code
DECLARE CorrelId Char;
SET CorrelId = CAST(InputRoot.MQMD.CorrelId as CHARACTER ccsid InputRoot.MQMD.CodedCharSetId encoding InputRoot.MQMD.Encoding);
IF (TRIM(CorrelId)) = 'ErrorM' THEN
SET OutputDestinationList.Destination.MQDestinationList.DestinationData[1].queueName = 'Q1';
ELSE IF (TRIM(CorrelId)) = 'bmsucc' THEN
SET OutputDestinationList.Destination.MQDestinationList.DestinationData[1].queueName = 'Q2';
END IF;
END IF;
But somehow the Destination list is not being set which leads me to believe that If statement is not working. Can anyone point me what is wrong with this If statement? I am assuming that we can convert CorrelId to Char and compare with a string. Is this assumption correct?
Thanks
Kiran |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Apr 04, 2006 1:56 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You should not be surprised that this is not working.
Quote: |
SET CorrelId = CAST(InputRoot.MQMD.CorrelId as CHARACTER ccsid InputRoot.MQMD.CodedCharSetId encoding InputRoot.MQMD.Encoding); |
The correlation id is a BYTE ARRAY and not a STRING!.
JMS might give you that impression, but the only transformation it does is that it gives you a hex representation of the values in the byte array see "=ID:xxxxxxx" and it does not get translated (CCSID)
Values in the byte array may not be in the char or string range ex: 0x00 which is a string terminator in C.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
JT |
Posted: Wed Apr 05, 2006 6:45 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Quote: |
I am assuming that we can convert CorrelId to Char and compare with a string. Is this assumption correct? |
Yes. We've done this in the past:
Quote: |
Executing statement 'DECLARE application CHARACTER SUBSTRING(CAST(InputRoot.MQMD.CorrelId AS CHARACTER CCSID InputRoot.MQMD.CodedCharSetId) FROM 1 FOR 3);' at (.Transform_COBOL_to_XML.Main, 107.4).
Evaluating expression 'SUBSTRING(CAST(InputRoot.MQMD.CorrelId AS CHARACTER CCSID InputRoot.MQMD.CodedCharSetId) FROM 1 FOR 3)' at (.Transform_COBOL_to_XML.Main, 107.4 .
Evaluating expression 'CAST(InputRoot.MQMD.CorrelId AS CHARACTER CCSID InputRoot.MQMD.CodedCharSetId)' at (.Transform_COBOL_to_XML.Main, 107.5 .
Evaluating expression 'InputRoot.MQMD.CorrelId' at (.Transform_COBOL_to_XML.Main, 107.63).
Evaluating expression 'InputRoot.MQMD.CodedCharSetId' at (.Transform_COBOL_to_XML.Main, 107.106).
Finished evaluating expression 'CAST(InputRoot.MQMD.CorrelId AS CHARACTER CCSID InputRoot.MQMD.CodedCharSetId)' at (.Transform_COBOL_to_XML.Main, 107.5 . This resolved to 'CAST(X'495652323030363031393134323133323233342020202020' AS CHARACTER CCSID 819 )'. The result was ''IVR2006019142132234 ''.
Finished evaluating expression 'SUBSTRING(CAST(InputRoot.MQMD.CorrelId AS CHARACTER CCSID InputRoot.MQMD.CodedCharSetId) FROM 1 FOR 3)' at (.Transform_COBOL_to_XML.Main, 107.4 . This resolved to 'SUBSTRING('IVR2006019142132234 ' FROM 1 FOR 3)'. The result was ''IVR''.
|
Activate the debug trace to see what's being evaluated. My guess would be the TRIM function is causing your comparsion to mis-fire. |
|
Back to top |
|
 |
zpat |
Posted: Wed Apr 05, 2006 7:15 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Why not use RFH2 fields for this? Or at least something more suitable such as APPLNAME in the MQH.
Using MQMD fields for something so different to their intended purpose is not a great idea in my view. |
|
Back to top |
|
 |
EddieA |
Posted: Wed Apr 05, 2006 4:36 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Quote: |
My guess would be the TRIM function is causing your comparsion to mis-fire. |
Or the CorrelID isn't in the Character Set described by InputRoot.MQMD.CodedCharSetId.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Apr 05, 2006 6:16 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Or it's been created by something else and isn't inside the char/string restrictions. Like I said it is ALLWAYS a bad idea to treat messageid or correlationid as a string because there cannot be a guarantee that the content conforms to the char/string restrictions...
Treat it as a byte array and compare the bytes.
That should be foolproof. No need to translate from and unknown (no conversion table) CCSID either.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|