This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Need help for creating Asynchronus Job in J2EE Environment - Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Need help for creating Asynchronus Job in J2EE Environment - Tomcat" Watch "Need help for creating Asynchronus Job in J2EE Environment - Tomcat" New topic
Author

Need help for creating Asynchronus Job in J2EE Environment - Tomcat

prabal nandi
Greenhorn

Joined: Jun 28, 2011
Posts: 28

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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41062
    
  43
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.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help for creating Asynchronus Job in J2EE Environment - Tomcat
 
Similar Threads
WAS WorkManager
hosting J2ee application
Running a servlet using Apache Web Server 2.0.47
Unable to do a jndi lookup. Getting Exception
Need sample code for Workmanager in Tomcat