【发布时间】:2015-04-03 21:39:53
【问题描述】:
我正在编写一个文件轮询实现并试图确定是否需要使用 AcceptOnceFileListFilter。 FileProcessor 将执行的第一步是将文件移动到另一个目录。
轮询器“batchFilePoller”在轮询时是否使用多个线程?一个文件将被多个线程读取的情况下会出现竞争条件吗?在这种情况下,我假设我需要使用 AcceptOnceFileListFilter。
但是,如果轮询器仅使用池中的一个线程。 那么如果文件在下一个轮询时间之前移动并且它成功了,我假设文件没有被处理两次的可能性?
<int-file:inbound-channel-adapter id="batchFileInAdapter" directory="/somefolder" auto-create-directory="true" auto-startup="false" channel="batchFileInChannel" >
<int:poller id="batchFilePoller" fixed-rate="6000" task-executor="batchTaskExecutor" max-messages-per-poll="1" error-channel="batchPollingErrorChannel" />
</int-file:inbound-channel-adapter>
<int:channel id="batchFileInChannel"/>
<int:service-activator input-channel="batchFileInChannel" >
<bean class="com.foo.FileProcessor" />
</int:service-activator>
<task:executor id="batchTaskExecutor" pool-size="5" queue-capacity="20"/>
【问题讨论】:
标签: multithreading spring spring-integration file-processing