Reputation: 4719
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
Upvotes: 1
Views: 2010
Reputation: 174799
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()"
.
Upvotes: 3