How to write an SQL update trigger with 5 minute delay? (with a jsp websevice)
I am writing a SOAP webservice with java-axis which is interacting with an Android app and will set the status of the user as available or not.
I plan to implement a simple mechanism: Any request sent to the webservice will mark the user as available.
Also, after five minu开发者_运维百科tes of inactivity, the user shall be marked as offline.
How can i achieve this. I thought of writing an always running service which shall do this or an trigger which will run after five minutes of the user being marked available.
Any tips or solutions?
Why not have a column called LastSeenDateTime that is checked by subsequent activities to determine if use if "on line" within the last 5 minutes.
You could make this computed so you get true or false based on a DATEADD calculation
You'd need a scheduled task to search for "last on-line" values and set according which isn't ideal. A trigger in the SQL sense would keep a transaction open which is bad
If you wish to maintain state then you should have server side sessions and a session manager.
SessionManager could be a daemon or a cron job.
Calling an SQL trigger from JSP is not such a good idea.
精彩评论