1
votes

I am poling directory using inbound channel adapter. But , it keeps on poling the same file infinite times and not creating message payload.

Two levels of poling involved:

1 poll the parent directory and move the file to Inprogess folder

2 poll the inprogress directory and create message payload

issue - it is polling the files present in inprogress directory indefinite times but it is not creating any message payload and invoke the job. configurations below.

<int-file:inbound-channel-adapter id="pollDataFile"
    directory="file:////D:/Directory1"
    channel="inboundFileChannel" auto-startup="true" filter="compositeFilter">
    <int:poller default="true" fixed-rate="5000" time-unit="MILLISECONDS"/>
</int-file:inbound-channel-adapter>

<int:service-activator id="moveFileToInProgress" ref="handler" input-channel="inboundFileChannel" output-channel="filesInProcess" />

    <bean id="handler" class="com.spring.batch.util.FileCopyService"/>

    <int-file:outbound-channel-adapter
        id="filesCopyToInProcess" channel="filesInProcess"
        directory="file:////D:/InProgress"
        auto-create-directory="false" delete-source-files="true">
</int-file:outbound-channel-adapter>

<int-file:inbound-channel-adapter id="pollDataFileInProgress"
        directory="file:////D:/InProgress" prevent-duplicates="true"
        channel="filesInProcessToProcess" filter="compositeFilter">
        <int:poller default="true" fixed-rate="10000"  time-unit="MILLISECONDS"/>
    </int-file:inbound-channel-adapter>

    <int:transformer id="prepareJobLaunchRequest"
        input-channel="filesInProcessToProcess" output-channel="outboundJobRequestChannel">
        <bean class="com.spring.batch.util.FileMessageToJobRequest">
            <property name="job" ref="fileUploadJob" />
            <property name="fileParameterName" value="input.file.name" />
            <property name="beanReader" value="bean.reader" />
            <property name="beanWriter" value="bean.writer" />
            <property name="beanProcessor" value="bean.processor" />
        </bean>
</int:transformer>


<bean id="compositeFilter"
    class="org.springframework.integration.file.filters.AcceptAllFileListFilter" />
1

1 Answers

0
votes

prevent-duplicates="true" adds an AcceptOnceFileListFilter so you have conflicting filters (accept all and accept once); duplicate file names won't be processed.

Set prevent-duplicates="false".