Hello, I am using websphere compute grid version 8.0.
My output has to be in the format:
Header Record (Last field being the total records read)
Trailer ( With last field being the actual number of records written)
My requirement is that I need to track the total number of records retrieved in the result set and write it as a one of the fields in the header record of a text file. I am using the FileWriterPattern as an output stream. Since, WriteHeader gets invoked even before all the records are read, I can not write the record count.
Also, I need to write the Trailer Record once all the records are written. I didnot find an API which is the counter part of WriteHeader().
I notice that framework always passes the domain object build in the Reader Implementation class ( am using JDBCReader) to the WriteHeader API.
Pinned topic Compute Grid API for Writing Trailer Record and Record Count in the Header
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-07-12T14:23:32Z at 2012-07-12T14:23:32Z by sspavan
sspavan 060000R0AA60 Posts
Re: Compute Grid API for Writing Trailer Record and Record Count in the Header2012-07-12T14:23:32ZThis is the accepted answer. This is the accepted answer.What is your processor implementation is it BatchJobStepInterface or BatchRecordProcessor ?
You can try the following to write the trailer information
Maintain a counter in your processor and incement it whenever you call outputStream.write() to write the actual record.
With BatchJobStepInterface you have destroyJobStep() method invoked at end of the processing, so in destroyJobStep() build a trailer record object using the counter above and call outputStream.write(trailerObj) to write the information to the file. In your writer implementation you may to do some additional coding to process the trailer obj as it would be different to normal record that you write to the file.