I have a requirement where in i need perform some asynchronous jobs in J2EE app (with Tomcat Server), basically need to send mail notifications and do cleanup job.
I know using threads directly is not advisable, what are the options i have in Tomcat. Websphere has commonj workmanager implementations, but i need some open source Async task executors for Tomcat.
I came accross Foo Commonj libraries, but don't know how to use it. Moreover it doesn't supplies the commonj.work.work class or related files.
Can anyone let me know about any open source implementation of Workmanager with proper example, Haven't seen a single thread providing the proper explanation to this topic.
I have actually never run into problems where using background threads created problems that weren't of my own making. I've definitely never noticed them interfering with Tomcat's operation, so I have no qualms using them. Check out the classes java.util.Timer and TimerTask, those provide a nice framework for setting and managing timed jobs. You can set them up and tear them down in a ServletContextListener.
But just to make sure: those jobs really need to run inside of Tomcat? Otherwise, a solution that uses a cron job to schedule invocation of a Java class would still be preferable.