Announcement Announcement Module
Collapse
No announcement yet.
Repalacing ItemReader resource with new input file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Repalacing ItemReader resource with new input file

    (In short i want to delete a file after job has completed and reader has finished with it)

    I have successfully created a reader of our custom file type

    I have got a directory poller that looks at the directory for files to process

    I pickup the files

    I pass to the item reader the resource for a given file read it process it etc

    The job ends we look again setting resource to next file and reuse job with new parameters

    once all files have been dealt with i wish to delete the process files then poll directory again to see if any more have turned up.

    Better still once single job for processing one file has finished delete the single file then continue to next file.

    Even though the job finishes executing and has completed status and has read to the end of file the reader still seems to have a buffer open to the file and will not allow for its deletion meaning that Iím processing the same files over and over again!

    Is there a way to de-reference the file? The job has finished and it has read through complete file i donít know why it is still referencing it.

    Cheers for help!

  • #2
    I have found that the file seems to be released fairly randomly. i have just been attempting deletion and random intervals and sometimes there is success.

    There must be a way of once a itemReader has read through complete resource to de reference it and delete it.

    Anyone can help?
    Last edited by josephanoakes; Jun 29th, 2009, 06:39 AM.

    Comment


    • #3
      Did you close the bufferedreader?? Or an input stream to it? That would be about the only way it would have a catch on it.

      We are actually doing something similiar here as well we forward read our files and send data back out as needed in a queue.

      Comment


      • #4
        Hi thanks for respsponse i have solved the issue.

        I ahve a reader that i created which is essentially a multi line reader.

        It has a delegate to a flatfileitemreader

        So when spring calls read it calls my reader. I then call read multiple times on the delagate giving me a single record that spans multipple lines build return object and return it from my reader.

        Once null is returned spring must call close on my read but i wasnt forwarding this on to the delagate reader.

        So now once i have recieved a null from the flat file item reader i close it

        This means the file is no longer referenced and can be deleted YAY!

        Comment

        Working...
        X