SpringIntegrationPoller不会轮询在应用程序启动后进入目录的文件

SpringIntegrationPoller不会轮询在应用程序启动后进入目录的文件,spring,spring-integration,Spring,Spring Integration,我有一个spring批处理集成应用程序,其中SI part读取一个文件夹中的文件,并调用该文件的spring作业。现在,当我启动应用程序时,它会读取文件夹中的所有可用文件,但如果应用程序启动后出现任何文件,poller不会选择该文件。下面是我的代码 配置 <int:poller id="appPoller" default="false" fixed-rate="1000" max-messages-per-poll="1" > <int:advice-chai

我有一个spring批处理集成应用程序,其中SI part读取一个文件夹中的文件,并调用该文件的spring作业。现在,当我启动应用程序时,它会读取文件夹中的所有可用文件,但如果应用程序启动后出现任何文件,poller不会选择该文件。下面是我的代码

配置

<int:poller id="appPoller" 
default="false" 
fixed-rate="1000"  
max-messages-per-poll="1" >
    <int:advice-chain>
<ref bean="inputDirChangeAdvice"/> 
</int:advice-chain>

</int:poller>
<bean id="inputDirChangeAdvice" class="com.varun.processor.ChangeDirAdvice" />
<int:channel id="files"/>

<int:channel id="requests"/>

<int:channel id="statuses">
    <int:queue capacity="10"/>
</int:channel>

<int-file:inbound-channel-adapter   id="pollAppFiles"
                                    prevent-duplicates="true"
                                    ignore-hidden="true"
                                    directory="file:/"
                                    filename-pattern="*.DAT"
                                    channel="files">
                                    <int:poller ref="appPoller"/>
                                <int-file:locker ref="appLocker"/>
</int-file:inbound-channel-adapter>
<bean id="appLocker" class="com.varun.locker.APPFileLocker" />

<int:transformer id="prepareJobLaunchRequest"
    input-channel="files" output-channel="requests">
    <bean class="com.varun.transformer.FileMessageToJobRequest">
        <property name="job" ref="JobName"/>
        <property name="fileParameterName" value="AbsoluteInputFile"/>
    </bean>
</int:transformer>

<int:service-activator id="runJob" method="launch" input-channel="requests"
    output-channel="statuses">
    <bean class="org.springframework.batch.integration.launch.JobLaunchingMessageHandler">
        <constructor-arg ref="jobLauncher"/>
    </bean>
</int:service-activator>    

我正在使用轮询器上的建议,以便轮询器根据某些条件从动态位置读取数据

更新:

建议代码如下

public class ChangeDirAdvice extends AbstractMessageSourceAdvice {

@Autowired
@Qualifier("pollAppFiles.source")
private FileReadingMessageSource fileReadingMessageSource;


@Override
public boolean beforeReceive(MessageSource<?> source) {
    //calculate Dynamic directory location
    this.fileReadingMessageSource.setDirectory(newDirectory);
    return true;
}

@Override
public Message<?> afterReceive(Message<?> result, MessageSource<?> source) {
    // TODO Auto-generated method stub
    return result;
}
公共类ChangeDirAdvice扩展了AbstractMessageSourceAdvice{
@自动连线
@限定符(“pollAppFiles.source”)
私有文件ReadingMessageSource文件ReadingMessageSource;
@凌驾
接收前公共布尔值(MessageSource){
//计算动态目录位置
this.fileReadingMessageSource.setDirectory(newDirectory);
返回true;
}
@凌驾
接收后的公共消息(消息结果、消息源){
//TODO自动生成的方法存根
返回结果;
}

从配置角度看,一切都很好,加上此功能是现成的。因此,如果它不起作用,我们在这件事上有太多的争议

尽量减少应用程序以隔离问题

例如,不要使用
inputDirChangeAdvice
appLocker
。甚至只记录消息而不运行作业

也许他们中的一些人会忘记启动你的
pollAppFiles


如果您仍然确定从框架角度来看存在一些错误,请通过GitHub共享尽可能简单的应用程序,以便在本地播放。

我刚刚注意到,如果我在windows计算机上运行此应用程序,它会选择新文件,但当我将应用程序移动到UNIX计算机时,它不会。有任何限制吗在文件访问级别?虽然我尝试为文件(777)授予最大权限,但仍然没有响应…M-M-M。如何为目录授予最大权限?不熟悉此类问题。但这有助于调试应用程序并在
DefaultDirectoryScanner.listEligibleFiles()上设置断点
。还要注意使用的是
ignore hidden=“true”
。请确保您的新文件不是此类文件。只是为了确保,
ignore hidden=“true”
仅按文件名跟踪文件,对吧!!.b'z出于测试目的,我正在文件夹中复制相同的文件。??`在文件夹中复制相同的文件
…是否
防止重复=“true”`有什么要说的吗?在后台,它由
AcceptOnceFileListFilter
表示。因此,在Linux上,具有相同名称的不同
文件
对象被认为是相等的。对您来说有意义吗?这是我的pollerAdvice的一部分。我删除了pollerAdvice和locker,SI可以轮询静态目录,但当我添加我对民意测验者的建议它只进行一次民意测验。用我的建议代码更新我的问题。不确定我要去南方。。