Author |
Message
|
Bravo |
Posted: Fri Jun 02, 2006 9:39 am Post subject: Msg lenght is 0 in MQOutput node |
|
|
Centurion
Joined: 03 Oct 2005 Posts: 146
|
Hi Everybody,
I am trying to use recusive procedure.Its a simple flow
MQInput -->Compute1-->MQOutput-->Compute2-->MQOutput2 and here is the peice of code.
Code: |
CREATE COMPUTE MODULE RESUSE_MSG_FLW_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE rOutRoot REFERENCE TO OutputRoot;
DECLARE rInRoot REFERENCE TO InputRoot;
DELETE FIELD rOutRoot.Properties;
CALL CopyMessageHeaders(rInRoot,rOutRoot);
DECLARE KeyData CHARACTER;
SET KeyData = 'Hello ';
Call createXMLMsg(rInRoot,rOutRoot,KeyData);
RETURN TRUE;
END;
END MODULE;
CREATE COMPUTE MODULE RESUSE_MSG_FLW_Compute1
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE rOutRoot REFERENCE TO OutputRoot;
DECLARE rInRoot REFERENCE TO InputRoot;
DELETE FIELD rOutRoot.Properties;
CALL CopyMessageHeaders(rInRoot,rOutRoot);
DECLARE KeyData CHARACTER;
SET KeyData = 'Hello ESQL';
Call createXMLMsg(rInRoot,rOutRoot,KeyData);
RETURN TRUE;
END;
END MODULE;
CREATE PROCEDURE CopyMessageHeaders(IN rInRoot REFERENCE, IN rOutRoot REFERENCE) BEGIN
DECLARE I INTEGER;
DECLARE J INTEGER;
SET I = 1;
SET J = CARDINALITY(rInRoot.*[]);
WHILE I < J DO
CREATE LASTCHILD OF rOutRoot DOMAIN FIELDNAME(rInRoot.*[I]);
SET rOutRoot.*[I] = rInRoot.*[I];
SET I = I + 1;
END WHILE;
SET rOutRoot.MQMD.Format = 'MQSTR';
SET rOutRoot.MQMD.Expiry = -1;
END;
CREATE PROCEDURE createXMLMsg(IN rInRoot REFERENCE, INOUT rOutRoot REFERENCE,In KeyData character)
BEGIN
SET rOutRoot.XML.Log.InterfaceID = 'TEST';
SET rOutRoot.XML.Log.IOFlag = 'I';
SET rOutRoot.XML.Log.RunTimestamp = CURRENT_TIMESTAMP;
SET rOutRoot.XML.Log.MQMsgID = rInRoot.MQMD.MsgId;
SET rOutRoot.XML.Log.MQCorelID = rInRoot.MQMD.CorrelId;
SET rOutRoot.XML.Log.Key = KeyData;
SET rOutRoot.Properties.MessageDomain = 'XML';
END;
|
When I debug mode i can see the whole message in rOutRoot and in OutputRoot but in the MQOutput node,I am getting the message length is 0.
Could you please let me know where am i wrong _________________ Bravo |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 02, 2006 10:01 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
Bravo |
Posted: Fri Jun 02, 2006 10:27 am Post subject: |
|
|
Centurion
Joined: 03 Oct 2005 Posts: 146
|
Thanks for your quick response Jeff..Actually I am not getting problem with the MQMD Header but with body of the message.
In my first post there are two reuse procedures CopyMessageHeaders()
and createXMLMsg() outside the MODULE but with the below code I have CopyMessageHeaders() procedure outside the module and createXMLMsg() is within two compute modules.This works fine..
What am I doing wrong with the first peice of code.
Code: |
CREATE COMPUTE MODULE RESUSE_MSG_FLW_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE rOutRoot REFERENCE TO OutputRoot;
DECLARE rInRoot REFERENCE TO InputRoot;
DELETE FIELD rOutRoot.Properties;
CALL CopyMessageHeaders(rInRoot,rOutRoot);
DECLARE KeyData CHARACTER;
SET KeyData = 'Hello ';
Call createXMLMsg();
RETURN TRUE;
END;
CREATE PROCEDURE createXMLMsg()
BEGIN
SET OutputRoot.XML.Log.InterfaceID = 'TEST';
SET OutputRoot.XML.Log.IOFlag = 'I';
SET OutputRoot.XML.Log.RunTimestamp = CURRENT_TIMESTAMP;
SET OutputRoot.XML.Log.MQMsgID = InputRoot.MQMD.MsgId;
SET OutputRoot.XML.Log.MQCorelID = InputRoot.MQMD.CorrelId;
SET OutRoot.XML.Log.Key = KeyData;
SET OutputRoot.Properties.MessageDomain = 'XML';
END;
END MODULE;
CREATE COMPUTE MODULE RESUSE_MSG_FLW_Compute1
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE rOutRoot REFERENCE TO OutputRoot;
DECLARE rInRoot REFERENCE TO InputRoot;
DELETE FIELD rOutRoot.Properties;
CALL CopyMessageHeaders(rInRoot,rOutRoot);
DECLARE KeyData CHARACTER;
SET KeyData = 'Hello ESQL';
Call createXMLMsg(rInRoot,);
RETURN TRUE;
END;
CREATE PROCEDURE createXMLMsg()
BEGIN
SET OutputRoot.XML.Log.InterfaceID = 'TEST';
SET OutputRoot.XML.Log.IOFlag = 'I';
SET OutputRoot.XML.Log.RunTimestamp = CURRENT_TIMESTAMP;
SET OutputRoot.XML.Log.MQMsgID = InputRoot.MQMD.MsgId;
SET OutputRoot.XML.Log.MQCorelID = InputRoot.MQMD.CorrelId;
SET OutRoot.XML.Log.Key = KeyData;
SET OutputRoot.Properties.MessageDomain = 'XML';
END;
END MODULE;
CREATE PROCEDURE CopyMessageHeaders(IN rInRoot REFERENCE, IN rOutRoot REFERENCE) BEGIN
DECLARE I INTEGER;
DECLARE J INTEGER;
SET I = 1;
SET J = CARDINALITY(rInRoot.*[]);
WHILE I < J DO
CREATE LASTCHILD OF rOutRoot DOMAIN FIELDNAME(rInRoot.*[I]);
SET rOutRoot.*[I] = rInRoot.*[I];
SET I = I + 1;
END WHILE;
SET rOutRoot.MQMD.Format = 'MQSTR';
SET rOutRoot.MQMD.Expiry = -1;
END;
|
Any suggestion _________________ Bravo |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 02, 2006 10:31 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Bravo wrote: |
Thanks for your quick response Jeff..Actually I am not getting problem with the MQMD Header but with body of the message. |
Yes, but you still aren't creating OutputRoot.XML with the correct parser. So you're having the same problem from the other thread, but with a different child of OutputRoot and a different parser. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 02, 2006 10:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Also, some general design comments.
You don't ever need to configure more than one MQOutput node to point to the same queue - and it's *slightly* worse if you do so becuase there are more OOProcs. It's also very very confusing to read.
If you need to send more than one message to a queue based on a single input message, then you can use the PROPAGATE esql function.
Secondly, most people use "recursive procedure" to mean a procedure that calls itself. And it doesn't look like your procedures do. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Bravo |
Posted: Fri Jun 02, 2006 12:09 pm Post subject: |
|
|
Centurion
Joined: 03 Oct 2005 Posts: 146
|
Jeff,
I am using different queues for each MQOutpt nodes. _________________ Bravo |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 02, 2006 1:18 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You could use a distribution list, then. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jun 02, 2006 3:08 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You might try this:
Code: |
CREATE PROCEDURE CopyMessageHeaders(IN rInRoot REFERENCE, IN rOutRoot REFERENCE) BEGIN
DECLARE I INTEGER;
DECLARE J INTEGER;
DECLARE myname CHARACTER NULL;
DECLARE mydname CHARACTER NULL;
SET I = 1;
SET J = CARDINALITY(rInRoot.*[]);
WHILE I < J DO
SET myname = FIELDNAME(rInRoot.*[I];
SET mydname = DOMAINNAME(rInRoot.*[I];
CREATE LASTCHILD OF rOutRoot DOMAIN mydname NAME myname;
SET rOutRoot.*[I] = rInRoot.*[I];
SET I = I + 1;
END WHILE;
SET rOutRoot.MQMD.Format = 'MQSTR';
SET rOutRoot.MQMD.Expiry = -1;
-- add the XML parser
CREATE LASTCHILD OF rOutRoot DOMAIN 'XML' NAME 'XML';
END;
|
Enjoy -- from memory so no guarantees  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Bravo |
Posted: Fri Jun 02, 2006 3:17 pm Post subject: |
|
|
Centurion
Joined: 03 Oct 2005 Posts: 146
|
It worked..Thanks Fjb and Jeff for the response. _________________ Bravo |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Jun 02, 2006 3:48 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
fjb_saper wrote: |
You might try this:
Code: |
-- add the XML parser
CREATE LASTCHILD OF rOutRoot DOMAIN 'XML' NAME 'XML'; |
|
This is exactly and only the missing piece. And it probably better belongs as the first line of "createXMLMsg" procedure, and not in CopyMessageHeaders. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|