hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: SessionRequest, SessionRequestCallback and other nio stuff...
Date Fri, 02 Feb 2007 18:42:10 GMT
On Fri, 2007-02-02 at 18:18 +0100, Stojce Dimski wrote:
> Oleg,
> 
> Many thanks for your time and effort... I would be very grateful if you
> can give me some advice on this...
> I have to orchestrate two parts which acts asynchronously, I don't see
> an elegant way to wait in handle method of server-side.... I need a
> server part to 'waits efficiently' for client part to finish his job of
> retrieving the response, and after that to get and stream to source the
> client response...
> 
> Do you have some suggestions as how to design this ?
> 

Stojce,

I bet the complexity of NIO programming model will drive you up the wall
on more than one occasion. Brace for it.

Here's what I think you should be doing:

(1) First off, one important thing to understand about NIO is that the
application does not have to react to I/O events if it is unable to
process them. So, after having received an incoming connection you
should initiate a request for an outgoing connection, update the HTTP
context accordingly and move on without blocking the I/O thread

(2) If you start receiving 'input ready' events while the outgoing
connection is still being open, you should suspend 'input ready' events
by calling #suspendInput() on the incoming connection.

(3) Once you receive a 'connection open' event for the outgoing
connection, re-enable 'input ready' events by calling #enableInput() on
the incoming connection.

(4) Start pumping data

Hope this helps

Oleg

> P.S. Regarding the nio connection pooling maybe I can help you, next
> week maybe I could give it a try, and gt back to you with something...
> 
> Thanks,
> Stojce
> 
> 
> ---------------------------------------------------------------------
> 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