I have a question. I have web app (written in struts, app buisness logic is in EJB) and I want it (www) to cyclic invoke some service method from EJB in defined period of time. Now I have service jsp page with "meta http-equiv="Refresh" and the method is invoked in struts Action. This is not good for me because it requires "user-admin" interaction with the page. I need solution transparent to the user. I consider servlet with some timer but now I see it is not good ide at all. Is there some good and simple solution for my problem. This should be something in shape of little deamon running in background on www server as a part of app and with ability of reading 2 parametrs from setup.properties: interval of invoking service method and on/off param.
You could try using EJB timers or some open source Java background processing tool, such as Quartz job scheduler. It has JavaEE integration right inside the servlet layer.
I wish you success with your project!
SCJP 6 (86% - the hard way), SCBCD 5 (81% - the hard way)
Joined: Mar 19, 2010
Despite my previous hunch that servlet with timer is bad idea, this solution accoured to be working just fine. Short description what I have done to solve my specific problem (as I mentioned before it had to be simple):
- new servlet with <load-on-startup>1</load-on-startup> set in web.xml (app server runs it when app starts - this is what i needed)
- parameters from setup.properties are being read in servlet (in method invoked from init)
- using quartz library a job is being created and initialized with parameters (added 2 new classes: Job and scheduler )
- EJB facade service method is being invoked from job class
Works fine, transparent to the user, does not disturb in normal using the application. Mission accomplished.
Krum thank You for reply, it helped me to verify my solution.
Joined: Mar 14, 2010
Glad to know that my advice has helped you.
Didn't you just use the EJBInvoker job, which comes with the Quartz distribution ?
Joined: Mar 19, 2010
Basically yes, I used Quartz scheduler to run my job (which implements Quartz Job). All this stuff is initialized from a servlet.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com