How can I implement a background task in user's session, to check if the user is making any progress or not? When the user takes too long, then the reserved resources can be released.
The requirement is when user selects the reservation, the resources are reserved for this user and the server is now waiting for next request to proceed.
If the user doesn't click proceed in next 60 seconds, the server should automatically release the reserved resources.
You could using java.util.Timer, java.util.TimerTask
to schedule and execute a cancel. Another popular scheduling library is quartz . But this could be an overkill.
A different approach to addressing this could be create a client side timer task which gets invokes a server 'cancel' function when no user interaction for certain period. Even then you would have to have a server process to cleanup resources when the user orphans the session by closing the browser for instance.
Also you could consider using session timeout .
Ok So I figured out how to put the solution in place.
Here are the steps that I followed
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.