Does anyone know how to use WatchService to monitor as AS400 IFS path?
I got the basic WatchService working for local Windows and network paths, but not for AS400 IFS paths.
The IFS path is basically a network path which I can access using some login. Assuming I logged successfully.
For Java 8
java.io.IOException: The request is not supported.
at sun.nio.fs.WindowsWatchService$Poller.implRegister(Unknown Source)
at sun.nio.fs.AbstractPoller.processRequests(Unknown Source)
at sun.nio.fs.WindowsWatchService$Poller.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
For Java 7
Exception in thread "Thread-2" java.lang.AssertionError: Should not get here
I'm not sure it's possible. A WatchService is tied to the file system, and I doubt that there's support for network shares there. Unlike NTFS and EXT*, it probably doesn't have a notification mechanism. I actually think it's bad design to let File and the default FileSystem handle network shares. Sure, it's easier, as long as you don't need anything "exotic" like WatchService or even logging in.
You could try a third party library like Apache Commons IO; it has FileAlterationMonitor. That uses polling though, so it's not as efficient as WatchService, but I doubt you'll find anything that does not use polling.
I ended up not using WatchService for the IFS folder but just to check for a particular file. If that file isn't there, sleep X, kind of like a while loop for say 30min or dedicated file whichever is earlier.
K. Tsang OCPJP OCMJEA SOACP PMP
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad: