-1

I am trying to develop a Java batch program using the IBM's JSR352 Implementation. Since the batch job involves iteratively processing huge number of records, I chose to implement it as Chunk Processing job. The problem statement is defined in detail over here.

Referring to the BonusUpdate example provided by IBM, they seem to be opening and closing the file within the reader's processItem() method for each of the 'N' number of records being read by the reader class.

Wouldn't this cause performance issue ? Can't we leave the file open until the last read ?

yathirigan
  • 5,027
  • 16
  • 61
  • 101
  • [What does your profiler tell you?](https://stackoverflow.com/questions/890222/analyzing-code-for-efficiency) –  Aug 24 '17 at 18:06
  • [Why we're not customer support for \[your favorite company\]](https://meta.stackoverflow.com/questions/255745/why-were-not-customer-support-for-your-favorite-company) –  Aug 24 '17 at 18:10

1 Answers1

1

The GeneratedCSVReader's readItem( ) method doesn't open the file every time. It gets opened when the batch container calls open( ).
The processItem method in the BonusCreditProcessor doesn't do any file access.

DFollis
  • 401
  • 2
  • 5
  • Looking at the logic in the reader's open method, they seem to be remembering a line number and during open they seem to advance cursor to that line number. if Open is not called every time, how does the readItem() method read next lines ? – yathirigan Aug 24 '17 at 19:03
  • 1
    readItem( ) increments recordNumber on line 54. At checkpoints the checkPointInfo( ) method is called and it returns the current recordNumber value. On a job restart, the checkpoint data is provided to open() which sets the local recordNumber to the right value for the last completed checkpoint. On the initial submit of the job there is no checkpoint data so the test on line 61 skips setting recordNumber and we start with the initial value of 0. – DFollis Aug 25 '17 at 19:46
  • Thank you. Is there any documentation available explaining this functioning of the BonusPayout example ? I still have some queries even after going through the code. Especially on the Listeners. – yathirigan Aug 28 '17 at 03:56
  • 1
    Hi, you can email me at skurz@us.ibm.com to discuss BonusPayout . – Scott Kurz Sep 05 '17 at 14:44