Here is a way that I have found to poll for text files in multiple directories, parallelly. I have five different types of files to be polled and processed. So, I created service activator and inbound channel adapter configuration for all the five types. Filter would filter out files matching a specific regex pattern, say *.txt.
<integration:poller id="typeOnePoller" fixed-delay="60000"
As my ServiceActivatorBean is common and has code that shall be reused for all feed types, I defined it once with scope prototype.
This approach works fine.
1. Is this approach correct? If there are better solutions please provide details.
2. Consider this case. I start the program and it polls all the 5 directories for files. Business rule demands under some conditions, we need to stop the application from polling for one or more of the feed types. If all pollers are stopped, then the program must terminate. If I used System.exit(), the JVM would be terminated, which eventually stops all the pollers instead of a specific poller(s). I would like to know if there is a way to stop polling a specific directory for a feed type dynamically / programatically?
Is it possible?
Appreciate your comments.