|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
Printing a message set in WBIMB v5.0 |
« View previous topic :: View next topic » |
Author |
Message
|
jborella |
Posted: Thu Jun 04, 2009 3:22 am Post subject: Reopening old thread. |
|
|
Apprentice
Joined: 04 Jun 2009 Posts: 26
|
I know this thread is old, but does anyone know whether its possible to inspect the message set at runtime somehow?
I take it the answer is , but I might be lucky!
I'm working on a solution, which goes beyond pretty printing of the message set. To be exact I need to know which messages a message set contains at runtime. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jun 04, 2009 8:08 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5543 Location: Southampton
|
Sorry - not possible. Out of interest, why do you want to get that info? |
|
Back to top |
|
 |
Sandman |
Posted: Tue Jun 09, 2009 12:09 pm Post subject: |
|
|
Centurion
Joined: 16 Oct 2001 Posts: 134 Location: Lincoln, RI
|
Has anyone ever created a simple report from the xsd file that represents an MRM that would show the element names and CWF lengths? We often need to deliver these to COBOL developers, and asking them to hunt through xsd files isn't the most productive.
Thanks. |
|
Back to top |
|
 |
jborella |
Posted: Thu Jun 11, 2009 10:22 am Post subject: |
|
|
Apprentice
Joined: 04 Jun 2009 Posts: 26
|
kimbert wrote: |
Sorry - not possible. Out of interest, why do you want to get that info? |
Sorry for the late answer, but I've been away to become a father to our second child.
In the compagny where I work they use what they call hierarcic Cobol structures. Suppose You have some data which are hierarcic:
Customer
-- Account
---- Posting
So a Customer can have several accounts, which can each have several postings.
You could define this in Cobol with occurs-depending-on structures, but in my compagny it was decided a long time ago to represent this as a normalized flat structure. So the above could be represented as three independent Cobol records where they have the convention that the parent to an object is the nearest to the left of a particular type. Lets take an example, since it's very easy to understand:
C stands for customer
A stands for Account
P stands for posting
Lets say You have a structure
C
-- A
---- P
---- P
---- P
-- A
---- P
---- P
In this case You have a customer with two accounts. The first have three postings, the second has two. Using hierarcic Cobol structures, this could be represented as:
CAPPPAPP
In order to separate the Cobol records from each other You need a length and a type, so the generic cobol record to represent any record looks like:
Length (integer)
Type (String, in the example one of C, A, or P)
Data (One Copy book for each of C, A, and P)
My message set contains exactly a message as the one above. Doing a little magic, I can also generate the hierarcic representation of data as well as the independent records. Now I want to make some generic code enabling me to go from hierarcic to the dynamic record layout. The following is my attempt:
Code: |
DECLARE ns1 NAMESPACE 'http://www.example.org/NewXMLSchema';
DECLARE ns NAMESPACE 'http://www.example.org/CobolHierarkisk';
CREATE COMPUTE MODULE MyApplicationFlow_Compute
DECLARE numberOfRecords INTEGER 0;
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
SET Environment.Variables.tagHierarcy[1] = 'NIVEAUA';
SET Environment.Variables.tagHierarcy[2] = 'NIVEAUB';
CALL SerializeMessage(InputBody);
SET OutputRoot.Properties.MessageFormat = 'Binary1';
SET OutputRoot.Properties.MessageSet = 'I7FBP5C002001';
SET OutputRoot.Properties.MessageType = '{http://www.example.org/NewXMLSchema}:MFREC_AGG';
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
CREATE PROCEDURE SerializeMessage(IN root REFERENCE) BEGIN
FOR elem AS root.*[] DO
IF EXISTS(SELECT F.* FROM Environment.Variables.tagHierarcy[] AS F where F = FIELDNAME(elem))
THEN
SET numberOfRecords = numberOfRecords + 1;
SET OutputRoot.MRM.ns1:MFREC[numberOfRecords].ns1:RECID = FIELDNAME(elem);
SET OutputRoot.MRM.ns1:MFREC[numberOfRecords].ns1:RECLEN = 0;
DECLARE datarec REFERENCE TO OutputRoot.MRM.ns1:MFREC[numberOfRecords];
CREATE LASTCHILD OF datarec NAMESPACE ns1 NAME FIELDNAME(elem);
MOVE datarec LASTCHILD;
CALL MoveVariables(datarec, elem);
CALL SerializeMessage(elem);
END IF;
END FOR;
END;
CREATE PROCEDURE MoveVariables(IN root REFERENCE, IN vals REFERENCE) BEGIN
FOR elem AS vals.*[] DO
IF NOT EXISTS(SELECT F.* FROM Environment.Variables.tagHierarcy[] AS F where F = FIELDNAME(elem))
THEN
DECLARE datarec REFERENCE TO root;
CREATE LASTCHILD OF datarec TYPE FIELDTYPE(elem) NAMESPACE ns1 NAME FIELDNAME(elem) VALUE FIELDVALUE(elem);
END IF;
END FOR;
END;
END MODULE;
|
The lines I would like to get rid of is:
SET Environment.Variables.tagHierarcy[1] = 'NIVEAUA';
SET Environment.Variables.tagHierarcy[2] = 'NIVEAUB';
this could be done if I could inspect the message set in order to investigate which records I need to normalize. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jun 11, 2009 2:08 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5543 Location: Southampton
|
Nice explanation, and a clever piece of ESQL. I don't think you can do better than that. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jun 11, 2009 7:22 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
...
User Defined Properties?
.... |
|
Back to top |
|
 |
jborella |
Posted: Fri Jun 12, 2009 12:16 am Post subject: |
|
|
Apprentice
Joined: 04 Jun 2009 Posts: 26
|
kimbert wrote: |
Nice explanation, and a clever piece of ESQL. I don't think you can do better than that. |
Thank You. Thats also what I thought, but I wanted to be sure. |
|
Back to top |
|
 |
jborella |
Posted: Fri Jun 12, 2009 12:19 am Post subject: |
|
|
Apprentice
Joined: 04 Jun 2009 Posts: 26
|
mqjeff wrote: |
...
User Defined Properties?
.... |
That will be my fall back plan. I always have a principle that I want ask a programmer for information I can obtain myself.
Another Idea I'm working with is to take the xml representation of the message set, store it into a database, and then read it into the message flow as configuration. This is obviously a more complicated solution, so maybe User Defined Properties is still better. I haven't completely decided yet. |
|
Back to top |
|
 |
|
|
|
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
|
|
|
|