Announcement Announcement Module
Collapse
No announcement yet.
File read count Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • File read count

    I am having difficulty in trying to obtain a file read count within itemprocessor.

    I have read similiar posts that are related to file read counter and they all suggest obtaining the readCount within the stepexecutionlistener afterStep, this approach is not suitable as I need the readCount total within the current step, not when the step has finished.

    The purpose of trying to obtain readCount value within itemprocessor is that I am calculating the batch progress in which I pass back the value to the gui along with a number of other totals which are used for reporting purposes.

    I have tried extending itemStream within ItemProcessor and using the open method try obtain readCount within executionContext by searching for read.count key but I get an null pointer exception.

    Could anyone please put me in the right direction of obtaing a file readcount within itemprocessor?

  • #2
    What do you want exactly? The total number of items in your file or the item number that your file is currently reading?

    You will never get the total number of items in your processor because, by default, the reader does not know it. If you really want to do this, you need to compute that by scanning the whole file first before starting the step (beforeStep callback might suit that).

    Comment


    • #3
      Thank you for replying, I wanted to get the total number of lines read in a file.

      In the before step I can count the total number of lines read in a file and then put this variable in the executionstepcontext, ok i'll try that.

      Comment


      • #4
        That's what we did and it's working fine as long as the delimiter between two items are not too complicated (one line = one item is ideal of course)

        Comment


        • #5
          What way did you do you file read count within the before step. As I have come across an AbstractItemCountingItemStreamItemReader, did you use this?

          Comment


          • #6
            Originally posted by madphooka View Post
            What way did you do you file read count within the before step. As I have come across an AbstractItemCountingItemStreamItemReader, did you use this?
            No. How about reading the Javadoc of that class before asking the question. It clearly states it's counting the elements in order to be able to restart on the last one in case of failure.

            Just count the number of items in beforeStep and put them in your execution context.

            Comment

            Working...
            X