Author |
Message
|
rampriya |
Posted: Tue Aug 13, 2013 10:13 am Post subject: WMB File Handling with MQ Batch |
|
|
Newbie
Joined: 27 Jul 2009 Posts: 9
|
Hi,
I am currently trying to write batch of records into file using file output.
My Scenario would be
There are 1000 msgs (request) in the queue each request would invoke backend service (SOAP Request). Send the response to next output queue for further processing and also write the response to a file (would like to create single file, but with my code it is creating multiple files)
For each request I will get 1 to many response, like that I need to consolidate the response of all the 1000 msgs into 1 file, but with my current code it is creating multiple files.
Following is the code which I am using to send the request to the queue
Code: |
SET modelCount = CARDINALITY(inRef.tns:FindOrderResponse.orders[]);
SET z = 0;
WHILE z < modelCount DO -- send the Order info to invoice q
SET z = z +1;
CALL CopyMessageHeaders();
SET OutputRoot.MQMD.GroupId = X'000000000000000000000000000000000000000000000003';
SET OutputRoot.MQMD.MsgSeqNumber = z;
SET OutputRoot.MQMD.MsgFlags = MQMF_MSG_IN_GROUP;
IF (z = modelCount) THEN
SET OutputRoot.MQMD.MsgFlags = MQMF_LAST_MSG_IN_GROUP;
END IF;
SET OutputRoot.XMLNSC.findOrders.CustomerID = ev.load.CustomerID;
SET OutputRoot.XMLNSC.findOrders.OrderID = inRef.tns:FindOrderResponse.orders[z].OrderID;
PROPAGATE TO TERMINAL 'out1';
|
Following is the code to write to the file:
Code: |
IF ev.MQMD.MsgFlags = MQMF_MSG_IN_GROUP THEN
SET outRef1.CustomerID VALUE = ev.load.CustomerID;
SET outRef1.xmlBlob = InputRoot.XMLNSC.toJava.xmlBlob;
IF ev.MQMD.MsgSeqNumber = 1 THEN
SET OutputLocalEnvironment.WrittenDestination.Action = 'Create';
ELSE
SET OutputLocalEnvironment.WrittenDestination.File.Action = 'Append';
END IF;
PROPAGATE TO TERMINAL 'out2' DELETE NONE;
ELSE
SET outRef1.CustomerID VALUE = ev.load.CustomerID;
SET outRef1.xmlBlob = InputRoot.XMLNSC.toJava.xmlBlob;
SET OutputLocalEnvironment.WrittenDestination.Action = 'Append';
PROPAGATE TO TERMINAL 'out2' DELETE NONE;
SET OutputLocalEnvironment.WrittenDestination.Action = 'Finish';
PROPAGATE TO TERMINAL 'out3' DELETE NONE;
END IF;
|
But this code writing multiple file instead of creating single file, Can any one help me to find the solution for my problem.
Thanks,
Ramanujan
Last edited by rampriya on Tue Aug 13, 2013 10:55 am; edited 2 times in total |
|
Back to top |
|
|
smdavies99 |
Posted: Tue Aug 13, 2013 10:20 am Post subject: |
|
|
Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
some points to look at.
1) What is the version of the MQMD structure that supports message grouping
2) Use C O D E tags in your post as it makes it easier for us humans to read.
3) Have you analysed what is going on and why you are getting multiple messages with simple things like
- Strategically placed trace nodes
- User trace output
4) What do the messages when places on a queue look like? Is everything Ok including all the data in the MQMD? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
|
mqjeff |
Posted: Tue Aug 13, 2013 10:37 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
What place in the message tree does the FileOutput node use to determine what it should do? |
|
Back to top |
|
|
kash3338 |
Posted: Tue Aug 13, 2013 9:09 pm Post subject: Re: WMB File Handling with MQ Batch |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
rampriya wrote: |
But this code writing multiple file instead of creating single file, Can any one help me to find the solution for my problem. |
Code: |
IF ev.MQMD.MsgSeqNumber = 1 THEN
SET OutputLocalEnvironment.WrittenDestination.Action = 'Create';
ELSE
SET OutputLocalEnvironment.WrittenDestination.File.Action = 'Append';
.
.
SET OutputLocalEnvironment.WrittenDestination.Action = 'Append';
PROPAGATE TO TERMINAL 'out2' DELETE NONE;
SET OutputLocalEnvironment.WrittenDestination.Action = 'Finish'; |
At one place you have used,
Code: |
OutputLocalEnvironment.WrittenDestination.Action |
And at other place its,
Code: |
OutputLocalEnvironment.WrittenDestination.File.Action |
What is the setting in Records And Elements - Record Definition property in your FileOutput node? |
|
Back to top |
|
|
Simbu |
Posted: Tue Aug 13, 2013 9:51 pm Post subject: Re: WMB File Handling with MQ Batch |
|
|
Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
rampriya wrote: |
Following is the code to write to the file:
Code: |
IF ev.MQMD.MsgFlags = MQMF_MSG_IN_GROUP THEN
SET outRef1.CustomerID VALUE = ev.load.CustomerID;
SET outRef1.xmlBlob = InputRoot.XMLNSC.toJava.xmlBlob;
IF ev.MQMD.MsgSeqNumber = 1 THEN
SET OutputLocalEnvironment.WrittenDestination.Action = 'Create';
ELSE
SET OutputLocalEnvironment.WrittenDestination.File.Action = 'Append';
END IF;
PROPAGATE TO TERMINAL 'out2' DELETE NONE;
ELSE
SET outRef1.CustomerID VALUE = ev.load.CustomerID;
SET outRef1.xmlBlob = InputRoot.XMLNSC.toJava.xmlBlob;
SET OutputLocalEnvironment.WrittenDestination.Action = 'Append';
PROPAGATE TO TERMINAL 'out2' DELETE NONE;
SET OutputLocalEnvironment.WrittenDestination.Action = 'Finish';
PROPAGATE TO TERMINAL 'out3' DELETE NONE;
END IF;
|
|
Usage of LocalEnvironment is wrong here. Did you read InfoCenter on how to use LocalEnvironment with file nodes before you write the code. If not please read it. |
|
Back to top |
|
|
Tibor |
Posted: Thu Aug 15, 2013 1:23 am Post subject: |
|
|
Grand Master
Joined: 20 May 2001 Posts: 1033 Location: Hungary
|
Please check your FileOutput node, as Infocenter mentions: "If you set the Record definition property to Record is Whole File on the Records and Elements tab, messages received on the Finish File processing are ignored because the file has already been processed." |
|
Back to top |
|
|
|