Topic
  • 1 reply
  • Latest Post - ‏2012-07-12T14:23:32Z by sspavan
SuKalpa
SuKalpa
1 Post

Pinned topic Compute Grid API for Writing Trailer Record and Record Count in the Header

‏2012-07-05T20:35:10Z |
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)
Body
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.
Updated on 2012-07-12T14:23:32Z at 2012-07-12T14:23:32Z by sspavan
  • sspavan
    sspavan
    60 Posts

    Re: Compute Grid API for Writing Trailer Record and Record Count in the Header

    ‏2012-07-12T14:23:32Z  
    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.