Announcement Announcement Module
No announcement yet.
Always looking for files with MultiResourceItemReader Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Always looking for files with MultiResourceItemReader


    I'm a newbie in Spring Batch. I have inherited a batch process implemented with Spring Batch.
    This works well, except for one thing I'll try to describe.

    I launch parseJob and, when it's reading XML to process in bean parsingStepReader,
    read() method is been invoking always.

    The directory path_to_xml contains only one XML, invoke read() and return XML parsed, which is processed OK. Then, read() method is invoked again, return a null object, and is invoked again, return null... and so on.

    When debugging, MultiResourceItemReader read method try to read, does not read anything (all resources has already been readed), increment currentResources and return null.

    I have readed something about the job stops when the reader return a null object, but that read method returns null and reads again and again...
    I changed restartable to false, but does not work.

    The job is launched in Linux, batch mode, with andLineJobRunner
    Because of this problem, the .sh that launch the job does not finish, and resources are busy.

    How can I avoid this, or stop the job when resources (XML) input directory have already been processed?
    Any help would be very appreciated. Best regards.

    Beans file and Java class pieces are attached

    <batch:job id="parseJob" restartable="true" incrementer="jobParametersIncrementer">
    	<batch:flow parent="parseFlow"/>
    	<batch:flow .../>
    	<batch:flow .../>
    <batch:flow id="parseFlow">
    	<batch:step id="parsingStep">
    		<batch:tasklet start-limit="100" allow-start-if-complete="true" transaction-manager="..." task-executor="taskExecutor" throttle-limit="$...">
    			<batch:chunk reader="parsingStepReader" writer="..." processor="..." commit-interval="..." skip-limit="10000000">
    					<batch:include class="java.lang.Exception" />
    				<batch:listener ref="iwListener" />
    				<batch:listener ref="mySkipListener" />
    				<batch:listener ref="myStep1Listener" />
    				<batch:include class="java.lang.Exception" />
    <!-- -->
    <bean id="bpfReader" class="org.springframework.batch.item.xml.StaxEventItemReader" scope="prototype">
    	<property name="fragmentRootElementName" value="..." />
    	<property name="unmarshaller" ref="..." />
    	<property name="strict" value="false" />
    <bean id="multiresourceItemReader" class="...SyncMultiResourceItemReader" abstract="true">
    	<property name="strict" value="false" />
    	<property name="delegate" ref="bpfReader" />
    <bean id="parsingStepReader" parent="multiresourceItemReader" scope="step">
    	<property name="resources" value="<path_to_xml>" />

    public class SyncMultiResourceItemReader<T> extends MultiResourceItemReader<T> {
    	. . .
    	public T read() throws Exception, UnexpectedInputException, ParseException {
    		synchronized (this) {
    	. . .