I have a servlet will not stop/start when the application is reloaded. The only way to currently get rid of it is to cycle the JVM. Currently each time I attempt to reload the application, I get an additional servlet running. The premise of this servlet is to process a resend queue every 5 minutes. The servlet starts onload, creates a thread that sleeps for 5 minutes then runs the resend logic. This is old code that I'm maintaining and if there is a better way to activate the resend logic, I'm all ears. Here's the current code:
public class MgBridgeResendHelper extends HttpServlet { private static final long serialVersionUID = 6047999961405830191L;
The 'resend thread' is not a good idea in the servlet.
Firstly it should be moved into a separate processing class, but it should also have a shutdown hook to stop the thread gracefully but you will also need to have a ContextListener that stops the thread when the context gets reloaded, as this will not cause the shutdown hook to fire.