Results 1 to 3 of 3

Thread: MultiResourceItemReader does not read files added to a folder after initialization

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Posts
    175

    Default MultiResourceItemReader does not read files added to a folder after initialization

    Hi,

    I've a job which processes log files one by one from a folder i.e. *.log

    However, what I've observed is that MultiResourceItemReader builds list of files from this location at application startup. So, if at startup there are no files but added at a later time, it doesn't read those files.

    Code:
    	<bean id="multiResourceItemReader" class="org.springframework.batch.item.file.MultiResourceItemReader">
    		<property name="resources" ref="logfileLocation" />
    		.....
    	</bean>
    Is this is by design or am I missing something?

  2. #2
    Join Date
    Dec 2010
    Posts
    175

    Default

    any idea or suggestions pls?

  3. #3
    Join Date
    Dec 2010
    Posts
    175

    Default

    It appears to me as a design issue based on what I've observed below:

    At the time of Spring context initialization i.e. at application startup there are no files in the location the job is referring to, as shown in the log below:

    Code:
    2012-08-13 18:36:15,271 INFO  - Initializing No of resources for MultiResourceReader - 0      --setResources called here
    2012-08-13 18:36:15,505 INFO  - Starting beans in phase 2147483647
    2012-08-13 18:36:15,505 INFO  - Starting Quartz Scheduler now
    2012-08-13 18:36:15,505 INFO  - Root WebApplicationContext: initialization completed in 4562 ms
    After initialization, a second job runs which loads the file into input location of job using MultiResourceReader. Then when the job runs the MultiResourceReader does not read or identify files added after spring context initialization and fails with the error.

    Code:
    2012-08-13 18:50:00,203 INFO  - Job: [FlowJob: [name=readFiles]] launched with the following parameters: []
    2012-08-13 18:50:00,234 INFO  - Job [readFiles] is starting
    2012-08-13 18:50:00,312 INFO  - Executing step: [loadFiles]
    2012-08-13 18:50:00,343 WARN  - No resources to read. Set strict=true if this should be an error condition.
    2012-08-13 18:50:00,375 INFO  - Reading a line from MultiResourceReader
    NOTE: The log printed in the previous log output is not shown in the log statements above i.e. the setResources is not called when the job executes.

    Hence, it appears as if MultiResourceReader works only when resources are available only during Spring context initialization and is unable to detect resources added/removed at runtime.

    Any suggestions?

Posting Permissions

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