Stopping a file inbound channel adapter after one one file is read

喜你入骨 提交于 2019-11-28 06:27:51

问题


Our application uses a Spring Integration file:inbound-channel-adapter to poll a directory to listen to when a file is dropped there. Spring Integration then starts a Spring Batch job, handing over to the job the path and name of the file to process.

Obviously, the file poller continues to run even after a file has been processed by the Spring Batch job. So, the Spring context remains open and the application does not terminate. Is there a way, programatically or through configuration (preferable), to stop the poller after one file has been read?

Thanks


回答1:


You can use a FireOnceTrigger on the poller, or one of the techniques described in addition to that, in this answer.

To programmatically stop the adapter, close() the context, or call adapter.stop() (@Autowire the adapter as a SourcePollingChannelAdapter. Or use a <control-bus/> and send a message with payload "adapterId.stop()".



来源:https://stackoverflow.com/questions/25229145/stopping-a-file-inbound-channel-adapter-after-one-one-file-is-read

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!