|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Collector node records loop |
« View previous topic :: View next topic » |
Author |
Message
|
ninar |
Posted: Fri Jul 31, 2020 3:54 pm Post subject: Collector node records loop |
|
|
Newbie
Joined: 13 Mar 2009 Posts: 5
|
Hi
IIB 10, Linux.
MQInput -> Collector -> Compute -> MQOutput
XMLNSC -> XMLNSC
MQIn will receive thousands of records every 30 mins, Collector has quantity '0' and Timeout '1800' setting. Map with output xmlnsc, add some more parameters, loop with all these records and send the final response to queue.
I'm testing with 4/5 records at the moment, in debug mode, after collector node, I can see the records under collection field and in compute node also, I can see, below is the example.
Code: |
Message
- Properties
- Collection
- CollectionName
- Request
- Properties
- MQMD
- XMLNSC
- Item
- Request
- Properties
- MQMD
- XMLNSC
- Item
- Request
- Properties
- MQMD
- XMLNSC
- Item |
I'm using FOR statement to loop through each Request, to get data in XML. Only the Request1 is working, the remaining records are not getting referenced. I used while too, same while and for statements for other flows seems to be working fine. Am I missing something here?
Code: |
FOR inputRef AS InputRoot.Collection.Request[] DO
FOR inputRecRef AS InputRoot.Collection.Request.XMLNSC.Item[] DO
SET outputRef.field1 = inputRecRef.field1;
SET outputRef.field2 = inputRecRef.field2;
SET outputRef.field3 = inputRecRef.field3;
END FOR;
END FOR; |
For statement is looping for the input record count times, but it always points to first Request & first Item.
I tried WHILE/LASTMOVE & NEXTSIBLING statements, with similar output just with first record. I'm aware storing data on DB is another option, but MQ/File were the given options. I'm trying MQ option. Any info on this helps. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Jul 31, 2020 8:31 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Your input is wrong and I am surprised you're getting anything at all.
I would have expected your code to read:
Code: |
FOR inputRef AS InputRoot.Collection.CollectionName.Request[] DO
FOR inputRecRef AS InputRoot.Collection.CollectionName.Request.XMLNSC.Item[] DO
SET outputRef.field1 = inputRecRef.field1;
SET outputRef.field2 = inputRecRef.field2;
SET outputRef.field3 = inputRecRef.field3;
END FOR;
END FOR; |
Notice the difference with CollectionName between Collection and Request.
You could potentially replace it with a '*'.
You don't seem to be changing outputRef between the two for loops. So if you wanted all the input values you'll have to append as last child of the parent (outputRef).
Hope it helps  _________________ MQ & Broker admin |
|
Back to top |
|
 |
ninar |
Posted: Sat Aug 01, 2020 5:13 am Post subject: |
|
|
Newbie
Joined: 13 Mar 2009 Posts: 5
|
Thanks for the reply.
Quote: |
Your input is wrong and I am surprised you're getting anything at all. |
Sorry, I gave the incorrect path.
Code: |
Message
- Properties
- Collection
- CollectionName
- Request
- Properties
- MQMD
- XMLNSC
- Item
- Request
- Properties
- MQMD
- XMLNSC
- Item
- Request
- Properties
- MQMD
- XMLNSC
- Item |
So, I believe the below path is correct.
Code: |
DECLARE inputRef REFERENCE TO InputRoot.Collection.Request;
|
I tried setting collection name * and RecordInput,
Code: |
DECLARE inputRef REFERENCE TO InputRoot.Collection.RecordInput.Request[];
|
but the references didn't work as CollectionName is also child of Collection.
Quote: |
You don't seem to be changing outputRef between the two for loops. So if you wanted all the input values you'll have to append as last child of the parent (outputRef).
|
The first FOR loop looks for first Request under Collection, second FOR loop looks for the Item in the first Request. Once the record is written, it has to move to second Request and Item in the second Request, which is not working.
I tried WHILE loop, with some dummy values, its exiting after first writing first record.
Code: |
WHILE LASTMOVE(inputRef) DO
SET outputRef.field1 = '1';
SET outputRef.field2 = '2';
SET outputRef.field3 = '3';
MOVE inputRef NEXTSIBLING NAME 'Request';
END WHILE;
|
I couldn't get how to try with LASTCHILD in this scenario. I'm working on it.
The cursor never moves to the second Request whatsoever. Are my references wrong? |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Aug 02, 2020 5:57 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The SET will not do because you'll be overwriting the values of loop 1 in loop 2, assuming that field1 of loop 1 is the same as field1 in loop 2.
This is why you'll need something like
Code: |
create lastchild of outref name 'field1' value input.recref.field1; |
You incorrectly assumed that the loop was exiting after the first iteration. What was happening was that each iteration was overwriting the values from iteration 1, so after the last iteration you have the same as after the first, as all the values within the iterations are the same...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|