Posted: Mon May 16, 2011 10:07 pm Post subject: FileRead node Parsing Issue
Novice
Joined: 05 Aug 2010 Posts: 21
I have a TDS file which has 1 lakh Records in it, each record is separated by a Line feed.
FileInput node is able to Parse it Record by record by using the below property:
Select Parsed Record Sequence if the file contains a sequence of one or more records that are serially recognized by the parser specified in Message domain. The node propagates each recognized record as a separate message. If you select the Record detection option, the parser specified in Message domain must be either XMLNSC or MRM (either CWF or TDS physical format).
But, the same file is not getting parsed by FileRead node, Problem here is FileRead parses the first record and the control doesn't come back to fetch the Second record and so on. It's not working similar to FileInput.
What could be done to Parse this now using FileRead??
It can be done by putting a compute node before and after the FileRead node. Then you use the variables the FileRead node is putting in LocalEnvironment after reading to update some Environment variables which you can use to do propagate in the first compute node until you reach the end of the file (ie, the FileRead node sets LocalEnvironment.File.Read.EndOfFile to TRUE)
The esql in the node before the FileRead node could look like this:
Code:
BEGIN
SET Environment.File.Offset = 0;
SET Environment.File.EndOfFile = FALSE;
WHILE Environment.File.EndOfFile = FALSE DO
CALL CopyMessageHeaders();
SET OutputLocalEnvironment.Destination.File.Offset = Environment.File.Offset;
PROPAGATE TO TERMINAL 'out';
END WHILE;
PROPAGATE TO TERMINAL 'out1';
RETURN FALSE;
END;
And the esql in the node after could look like this:
Code:
BEGIN
SET Environment.File.EndOfFile = InputLocalEnvironment.File.Read.EndOfFile;
SET Environment.File.Offset = InputLocalEnvironment.File.Read.NextRecordOffset;
RETURN TRUE;
END;
It can be done by putting a compute node before and after the FileRead node. Then you use the variables the FileRead node is putting in LocalEnvironment after reading to update some Environment variables which you can use to do propagate in the first compute node until you reach the end of the file (ie, the FileRead node sets LocalEnvironment.File.Read.EndOfFile to TRUE)
...
Thanks a lot for your sample code! It did a real good job in order to process each single line after each other of an input file. _________________ IBM Certified Solution Designer - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.0
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
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