This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Asynchronous processing in servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Asynchronous processing in servlets" Watch "Asynchronous processing in servlets" New topic

Asynchronous processing in servlets

Siva Krishnamurthy

Joined: Mar 24, 2004
Posts: 6
We are having a problem where in we need to do some processing asynchrnously in a servlet as it takes time to do that part.
Is it a good practice to spawn a thread inside a serrvlet?? Or can JMS be used? I'm new to the messaging technology..
Please help...
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
I think either one of them will be a good approach. There are a few concerns. For instance, if you're running this in a pure web container like Tomcat, you may not have a built in JMS service available, so you'd have to run one separately. In JBoss, I think it's taken care of, but that's different software.
But I don't see any reason why either approach wouldn't be okay. Using a separate thread seems a lot more simple and to the point. JMS would be more extensible in the future, but maybe you don't really need all that to do what you want. Options, options, options.

Kyle Brown
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
See this month's Javaranch Journal, where I write an article on EXACTLY THIS!

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at for other WebSphere information.
Siva Krishnamurthy

Joined: Mar 24, 2004
Posts: 6
Thanks for the info
I agree. Here's the link:
subject: Asynchronous processing in servlets
It's not a secret anymore!