Results 1 to 4 of 4

Thread: Repalacing ItemReader resource with new input file

  1. #1

    Post 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. #2

    Default

    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 at 05:39 AM.

  3. #3

    Default

    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.

  4. #4

    Default

    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!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •