我需要以程:
- 扫描文件夹并将传入文件从当前目录移动到另一个目录
- 调用一些回调方法
- 在上一个回调完成之前不处理新文件 所以我只需要一个正在处理的文件。
我尝试了这样的smth:
<file:inbound-channel-adapter id="filesIn" directory="/inbound">
<int:poller fixed-delay="1000"/>
</file:inbound-channel-adapter>
<file:outbound-channel-adapter id="filesOut" directory="/outbound"/>
<int:service-activator input-channel="filesIn"
output-channel="filesOut"
ref="handler"/>
但在这种情况下,处理程序执行发生在文件移动之前。
你几乎接近解决方案了!
只有您应该考虑的区别<publish-subscribe-channel>
用于filesIn
,而没有任何executor
配置,并且<service-activator>
(outbound-channel-adapter
( 作为该频道的第二个订阅者。
<file:inbound-channel-adapter id="filesIn" directory="/inbound">
<int:poller fixed-delay="1000"/>
</file:inbound-channel-adapter>
<int:publish-subscribe-channel id="filesIn"/>
<file:outbound-channel-adapter id="filesIn" directory="/outbound"/>
<int:outbound-channel-adapter input-channel="filesIn" ref="handler"/>
确保handler
不会使用其服务方法返回任何内容。 由于已经无处发送回复。