ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Message Headers not getting copied to output

Post new topic  Reply to topic
 Message Headers not getting copied to output « View previous topic :: View next topic » 
Author Message
sanu_mit
PostPosted: Thu Sep 04, 2003 10:35 pm    Post subject: Message Headers not getting copied to output Reply with quote

Apprentice

Joined: 03 Jul 2003
Posts: 25
Location: Kolkata

In order to meet my requirements, I devised a seperate method to copy the message headers from input to output.

The main flow runs as follows:
Code:
DECLARE InRoot REFERENCE TO InputRoot;
DECLARE OutRoot REFERENCE TO OutputRoot;

CALL CopyMessageHeaders(InRoot, OutRoot);
....................
.......................
.......................

CREATE PROCEDURE CopyMessageHeaders(IN InRoot REFERENCE, INOUT OutRoot REFERENCE)
BEGIN
     DECLARE I INTEGER;
     DECLARE C INTEGER;

     SET I = 1;
     SET C = CARDINALITY(InRoot.*[]);
     WHILE I < C DO
          SET OutRoot.*[I] = InRoot.*[I];
          SET I = I + 1;
     END WHILE;
END;


Although the flow gets deployed successfully, exception is thrown during execution saying that the output message do not have any valid header.

Any explanation as to why is this so happening? Must be that I am doing something wrong................

Thanks in anticipation.
Back to top
View user's profile Send private message Yahoo Messenger
Craig B
PostPosted: Fri Sep 05, 2003 6:19 am    Post subject: Reply with quote

Partisan

Joined: 18 Jun 2003
Posts: 316
Location: UK

Hi,

Im not sure you can copy the headers in this way within a procedure in WMQI V2.1. The OutputRoot and InputRoot are special message trees that are owned by a root parser. The root parser is special because it can invoke other parsers, and the parsers it invokes are determined by the names of the folders that are present in InputRoot and/or OutputRoot. When you are copying the headers in the standard way you have a line that is SET OuptutRoot.*[I] = InputRoot.*[I]; This will invoke a parser copy of the parser owned folder from the Input tree to the output tree.

When you declare a reference variable to a point in a message tree, then it points to a message tree field, that could have siblings and children. Therefore when you declare a reference variable to InputRoot and OutputRoot then the reference variable does not know that it is pointing to a place which is governed by the root parser. Therefore you lose the fact that the root parser is involved in this copy. So when you have the line SET outRef.*[I] = inRef.*[I] you no longer have the fact that this is special copying where a parser is involved. It is now just a tree copy between two reference variables that will just copy the fields. This means that in yor output tree, even if you get the correct structure of fields, these may not be owned by the parser who needs to own them and will look for them when writing a message.

This limitation has now been removed in V5.
_________________
Regards
Craig
Back to top
View user's profile Send private message
mgk
PostPosted: Fri Sep 05, 2003 8:09 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

The following is a copy of a post I made on the ibm.software.websphere.mqintegrator forum about a year or so ago. Basically it confirms what Craig says above, but it also includes some ESQL that performs the Header Copy inside a procedure that you are trying to do. As Craig says, this is not needed on V5, as the restriction of needing to pass a reference to OutputRoot in prder to refer to OutputRoot inside of a procedure or function was removed. However what was NOT removed is the behaviour of a reference to OutputRoot being different from the behaviour of OutputRoot itself, so this code may still be useful in V5 for certain situations...

==============
FORUM APPEND COPY
==============


The Correlation Name OutputRoot has a special property; that is, if a child
of it is referenced, it first checks to see if the child's name matches a known parsers name, and if it does a parser of that type is created (if it does not already exist) and any grandchildren are created under that parser.

EG. SET OutputRoot.XML.TestCase = 'Hello'; Creates the XML parser
and the XML Parser creates the field TestCase and sets its value to 'Hello'.
if the XML parser did not already exist.

This special behaviour does not occur when OutputRoot is used through a
reference, as we do not always know that the reference is pointing at THE OutputRoot when it is used.

Therefore, SET used on a REFERENCE to OutputRoot will NOT create a parser. However the CREATE statement with the DOMAIN clause will create the parser, and, once the parser exists, SET statements will work as they do when used on OutputRoot directly.

The following example demonstrates this, and shows how to copy headers using CREATE, DOMAIN and OutputRoot references passed to ESQL procedures.

Note that this problem is not specific to Functions/Procedures; it can
happen outside of any Function/Procedure if a reference to OutputRoot is
taken and used by SET before any necessary parsers are created.

Note that there is one special case that works on OutputRoot when used
with / without a reference, and that is SET OutputRoot = InputRoot; will work when used on references, because it uses a Root to Root parser copy

(see testWorksSpecial below).

Therefore, to fix your problem you need to CREATE the parser using the
DOMAIN clause of CREATE  before you SET elements under them.


Code:
/**************************************************************/

CALL testWorks( InputRoot , OutputRoot);

/*CALL testFails( InputRoot , OutputRoot);*/

/*CALL testWorksSpecial( InputRoot , OutputRoot);*/

CREATE PROCEDURE testWorks( IN InputRoot REFERENCE, IN OutputRoot REFERENCE )
BEGIN
  /*copy headers - this works with a REFERENCE to OutputRoot*/
  DECLARE I INTEGER;
  DECLARE X INTEGER;
  SET I = 1;
  SET X = CARDINALITY(InputRoot.*[]);
  WHILE I < X DO
    CREATE LASTCHILD OF OutputRoot DOMAIN FIELDNAME(InputRoot.*[I]); /*create the parser*/
    SET OutputRoot.*[I] = InputRoot.*[I]; /*copy values to the newly created parser*/
    SET I=I+1;
  END WHILE;

  /*Create the XML Parser before we use it*/
  CREATE LASTCHILD OF OutputRoot DOMAIN 'XML'; /*You should use LASTCHILD here*/
  SET OutputRoot.XML.TestCase.Out = 'Hello';
END;

CREATE PROCEDURE testFails( IN InputRoot REFERENCE, IN OutputRoot REFERENCE)
BEGIN
  /*copy headers using the standard header copy code*/
  /*Does NOT work for a REFERENCE to OutputRoot*/
  DECLARE I INTEGER;
  DECLARE X INTEGER;
  SET I = 1;
  SET X = CARDINALITY(InputRoot.*[]);
  WHILE I < X DO
    SET OutputRoot.*[I] = InputRoot.*[I];
    SET I=I+1;
  END WHILE;

  SET OutputRoot.XML.TestCase.Out = 'Hello';
END;

CREATE PROCEDURE testWorksSpecial( IN InputRoot REFERENCE, IN OutputRoot REFERENCE )
BEGIN
  SET OutputRoot = InputRoot;
  SET OutputRoot.XML.TestCase.Out = 'Hello';
END;

_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
sanu_mit
PostPosted: Sun Sep 07, 2003 8:04 pm    Post subject: Reply with quote

Apprentice

Joined: 03 Jul 2003
Posts: 25
Location: Kolkata

Thanks a lot to both Criag and Mgm for the explanation of the fact that caused the anomaly.

An extra bouquet of thanks Mgm for the workarround code to achieve the same goal.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Message Headers not getting copied to output
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.