Announcement Announcement Module
Collapse
No announcement yet.
Reading from multiple files and deleting upon completion Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading from multiple files and deleting upon completion

    Hi,
    I need to create a job that process files that exists in a directory and when each file is fully processed delete it.
    I am using MultiResourceItemReader to get the list of resources.

    How is the best way to achieve the deletion?

    Thanks,
    -Sam.

  • #2
    Use Tasklet, look for org.springframework.batch.sample.tasklet.FileDelet ingTasklet.java in samples

    Comment


    • #3
      Does it have to be after each file is fully processed, or can be it be after all the files are processed? If the latter, you could easily use a StepExecutionListener and delete the files in the afterStep. The former would be a lot trickier.

      Comment


      • #4
        I need the ItemReader instance used by the step.
        From the ItemReader I can get the list of processed reources.

        I don't see any method in the StepExecution that is passes to By using StepExecutionListenerSupport.afterStep.

        -Sam.

        Comment


        • #5
          Just inject the ItemReader into multiple beans, there's nothing wrong with doing that.

          Comment


          • #6
            In order to delete the file I actualy need acces to the Resource in the MultiResourceItemReader. There is no getter and the reources are private so I can't overide the class to create a getter.

            Do you have any other idea besides completely copying the MultiResourceItemReader to enable a getter?

            Comment


            • #7
              Can't you inject the resource into multiple beans?

              Comment


              • #8
                Hi, Try to do something in delegate.setResource()

                Comment

                Working...
                X