Spawning multiple threads inside a Servlet
We have a situtation where we need to crawl various sites/databases for information to perform a search. The most efficient way is to multithread the application as we all know. Since J2EE discourages custom Multithreading, we had to search for alternatives to accomplish this task.
We came across few interesting solutions using JMS/MDB. Other than using these is there a simpler way to accomplish this. Any help is appreciated...
Searching this way possibly takes a long time (even when using multiple threads). I've had a similar application a while back where I had to custom build a j2me midlet when a user access the download page. I solved it by going through the following steps:
1: user enteres what he wants in a webform.
2: webform is submitted to the server, which stored it in the database.
3: a second application which listenes on the database is automatically started and begins the process of compiling the midlet. While this compilation is in progress the webpage polls every 5 seconds to check if the midlet is completed.
4: once the midlet is completed, the application sets a flag in the database to 1.
5: the next poll from the client, the webserver sees the midlet is complete and starts streaming it to the client.
Using this approach, I disconnected the time consuming action of compiling the application from the actual webserver process. This has the added benefit that you can run it on a seperate server if need be.
You can port this to your situation by using the secondary application to perform the actual search and add the results of the search either to the database, or store in file on thefile system.
During the polling of the client, you can show a nice moving gif of a running clock or somethings like that.
Thanks Mark, Looks like a good idea...
Last Post: 09-09-2005, 08:12 AM
Last Post: 09-04-2005, 11:10 PM
By Loganathan in forum Java
Last Post: 01-25-2001, 12:48 AM
By Dhiraj Nilange in forum Java
Last Post: 12-10-2000, 02:59 PM
By Jerry Ball in forum Java
Last Post: 04-04-2000, 04:28 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL