hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: async http clients
Date Thu, 12 Jul 2007 21:35:14 GMT
On Thu, 2007-07-12 at 14:10 -0700, David Koski wrote:
> Hi,
> 
> I have been reading NHttpClient and I think I finally understand how  
> it all works, but I am a bit stuck with how to use it.  Let's say I  
> wanted to build something along the lines of a load balancer:  many  
> incoming connections, many outgoing connections, most are idle or  
> waiting for a response.
> 
> Focusing on the outgoing connections part, I want to have keep-alive  
> connections to a set of hosts, multiple connections per port.  For  
> example:
> 
> 	LB -> host1:80
> 	LB -> host1:80
> 	LB -> host1:80
> 
> 	LB -> host2:80
> 	LB -> host2:80
> 
> If I have a queue of operations I want to do, I can see how I might  
> use a series of ioReactor.connect() calls to create the connections  
> and have submitRequest() methods in my HttpRequestExecutionHandler  
> pull them off the queue and service them.
> 
> The problem I am having is dealing with the steady state.  I would  
> like to keep these connections around for a while (and indeed using  
> the DefaultConnectionReuseStrategy they are kept alive.  However, once  
> my queue drains and my submitRequest() method returns null, how do I  
> wake the handlers back up?  I can see any way to get the reactor to  
> call back into my handler without opening a new connection.
> 
> Am I missing something?  Or going about this the wrong way?
> 

Hi David

Just invoke IOControl#requestOutput() (implemented by all NHttp
connections) and it will cause the I/O reactor to fire up the
NHttpClientHandler#requestReady() event, which you can use to submit a
new request on that connection

Hope this helps

Oleg

> Thanks,
> David Koski
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Mime
View raw message