Spring Integration文件通道适配器无限次轮询文件而不创建消息有效负载

时间:2015-12-31 15:36:22

标签: spring-integration

我正在使用入站通道适配器进行poling目录。但是,它继续无限次地对同一文件进行极化,而不是创建消息有效负载。

涉及两个级别的极化:

1轮询父目录并将文件移动到Inprogess文件夹

2轮询inprogress目录并创建消息有效负载

问题 - 它无限期地轮询inprogress目录中存在的文件,但它没有创建任何消息有效负载并调用该作业。 配置如下。

<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 个答案:

答案 0 :(得分:0)

prevent-duplicates="true"添加了AcceptOnceFileListFilter,因此您会遇到冲突的过滤器(接受所有并接受一次);重复的文件名不会被处理。

设置prevent-duplicates="false"