DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=38950>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=38950 ------- Additional Comments From [EMAIL PROTECTED] 2006-04-14 09:57 ------- Reading the comments it is obvious to me that it is thought that using background threads is a bad thing. This is odd, because many of the books I have read on using servlets suggest using threads. So I suppose the real question is how do I do some action in the background in a Tomcat environment on a timer (as this is what I need to do) in addition to the "foreground" regular Http request handling. This problem is occuring right when I start the thread, we are not here talking about something that happens when a servlet is being reloaded or tomcat is being shut down. So while the particular http request that started the thread may have gone away, the servlet itself is still alive (that is init has run, and destroy had not been called). The JDBC driver is in the WebApp WEB-INF/lib directory, although it makes no difference to the problem if it is in the common/lib directory. The particular function I am doing here is a request queue, to remote servers which may or may not be available. The foreground requests put entries in a Postgresql table which the background thread tries to pass on to remote servers (which are not under my control). Normally they go through on first request but may take some time to respond, but sometimes the requests hang around for days on end (typically over weekends). My background thread wakes up, takes all pending requests, tries each, if they success marks them as complete in the table otherwise leaves them for next time. When it runs out of this batch it goes to sleep for a minute or so and then tries again. Currently, as I can not get Tomcat 5.5 to handle this as a background thread, I have split this out as a separate long running process, but this is not the way I want to proceed as it makes managing the system much more difficult. I can not believe that my need is a unique one, in fact a Google search shows many tutorials and the like which identify this senario, say that there is no architected way to do this, and then suggest using a background thread. Up until Postgresql 8.1 and Tomcat 5.5 this worked just fine, but the current combination simply does not work. Perhaps what is needed is an architected way of building timed requests into the Servlet framework. There would seem to be two obvious ways to do this. The first would be a configuration option that allowed a logical http request to be injected into the system periodically, and the second would be a API request that invoked some other method either after some interval or periodically but in both cases using the a valid context (in the broader sense of the word) for things like the Postgresql JDBC driver to work. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]