简体   繁体   中英

Alternatives to long polling?

I have an application in JAVA which checks from the ftp server, whether a given file is updated or not. If the file is updated, I download the file again.
I am using long polling to check, whether the file has been modified. So I ping the FTP server every 5 seconds and check whether the modified date of the file is changed or not. If the date is modified, I re-download the file again.
Is there a better way to perform this operation, other than long polling?

In general, there are two approaches for checking for updates.

The first is the one that you mentioned, and that is polling for changes periodically.

The second solution, is to register a "hook" which will be invoked once a specific action is occurs. For example, when pushing to a git repository, you can create a hook to automatically start a build of the source code.

In your case, option two is not applicable. There isn't an obvious way to make the FTP server ping you once the files change.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM