> I have a remote service that I call via cfhttp that does a processing
> task. It is a commercial service and our license is based on the
> number of simultaneous requests we can make against the service. So
> lets say that I have 5 "ports" available to me, i.e., I can have 5
> active requests at any given time. Additional requests will be refused
> by the remote service.
>
> On my side, I have a queue of requests that I need to get through.
> What I'm trying to design is a simple setup where it launches the 5
> allowed http requests using cfthread (each task is independent of the
> others) and when one of the threads completes, it goes and grabs the
> next item that needs to be sent to this remote service that way we are
> utilizing all 5 ports to full effect.
>
> I understand how to launch an individual thread. What I'm having
> difficulty wrapping my head around is how to have it go fetch the next
> item in the queue and launch a thread again until the queue has been
> processed.
>
> It kind of seems like what I want to be doing is having a top level
> variable that keeps track of what the next item in the queue is, then
> down at the thread level, have my threads in some sort of a "while"
> statement that keeps going until the queue is done, then have the
> completion of a thread return a value that launches that thread again
> with the current value of the top level variable and then changes the
> top level variable to the next item in the queue.

I would recommend that you use one thread to monitor the others. This
thread could wake every 500ms, for example, then check the progress of
the other threads, terminate unresponsive threads, and assign new
tasks.

There's an example of this in the Adobe Advanced ColdFusion 8
Development course, actually.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314411
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to