× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Aaron,

Here is an example that reads from a data queue and fires up a new
thread for each request. In this case it doesn't actually pull the
request from the queue unless it is a stop but you should be able to use
it with minor modification.

http://www.itjungle.com/fhg/fhg040605-story01.html

David Morris

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of albartell
Sent: Wednesday, September 13, 2006 9:35 AM
To: java400-l@xxxxxxxxxxxx
Subject: Reading (and threading) DataQueue entries - Best practices

Heyo,
 
Question #2 for the day.
 
Here is my scenario.  I need to listen to a keyed data queue in Java and
once I get a record I need to communicate with a remote server over
http. If
this process takes say 30 seconds there may be an additional 5 data
queue
entries waiting at that point for processing that were delayed because
the
http communication took so long.  
 
I have a handful of ideas on how to accomplish this task but want to
know
about any "Best Practices" others have found useful.
 
1. For each entry received into my Java program create a new job that
will
go out and do the communication. I don't like this option because I will
incur the JVM startup all over again.
 
2. Implement a Java threading process so that when each entry is read a
new
thread is spawned within the current job.
 
3. Starting multiple jobs (say 10 or so) that all listen to the same
data
queue. This lessens the chance that somebody will have to wait, but it
also
means that if 10 processes are running (which each is tied to a user
interaction) that the 11th person will have to wait until one of the
processes complete.
 
 
It seems like option 2 is the best (though I am not real fond of doing
my
own thread programming).  Are there other methods that I could use that
would also be good to consider?
 
Thanks,
Aaron Bartell


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.