synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Asankha C. Perera" <asan...@wso2.com>
Subject Re: A basic non-blocking http/s implementation for Axis2/Synapse
Date Wed, 11 Oct 2006 05:03:08 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Oleg<br>
<br>
I was looking at the example <a
 href="http://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/trunk/module-nio/src/examples/org/apache/http/nio/examples/AsyncHttpServer.java">AsyncHttpServer</a>
in the NIO extensions and am looking at the following two fragments of
code...<br>
<br>
<pre>   static class DefaultIoEventDispatch implements IOEventDispatch {
   ....
   public void connected(IOSession session) {
            ...
            httpService.registerRequestHandler("*", new HttpFileHandler());
            ...
            worker.start();
	    ...
        }
  &nbsp;...
</pre>
-------------------------<br>
<br>
public interface HttpRequestHandler {<br>
<br>
&nbsp;&nbsp;&nbsp; void handle(HttpRequest request, HttpResponse response, HttpContext
context) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
throws HttpException, IOException;<br>
}<br>
<br>
<br>
Does the above imply that we always need to create a new thread to
handle each new connection? Also, when Synapse receives a message it
may not know how to reply to it immediately - unlike a web server, as
the response may depend on the response received from another web
service to which the request needs to be forwarded. Hence at the
implementation of the HttpRequestHandler interface's handle() method we
have a problem.<br>
<br>
AsyncWeb exposes a HttpService.handleRequest(HttpRequest request)
method, where it is easier for us to handle just the received request.
Once we are ready to respond, we could use request.createResponse() and
perform a HttpResponse.commit(). So the processing of the request and
the response could take place over two distinct threads [of the common
worker thread pool]. They state that any methods invoked on the streams
returned by HttpRequest#getInputStream() and
HttpResponse#getOutputStream() will never block - and I guess this
implies that they have buffered the complete request in memory. As
Synapse runs on top of Axis2, we may not need to 'parse' the complete
XML messages for us to do play our role (say CBR), but I think we
should process them only after they have been fully read.. as we may
need to forward them to another service etc. according to the
configured rules we use.<br>
<br>
As AsyncWeb does not [yet] provide a stable client, we started to try
and develop our own transport, which is essentially a subset of a
standard http implementation - but which is very similar to your NIO
extensions - with the distinction mentioned above, which was borrowed
from AsyncWeb.<br>
<br>
thanks<br>
asankha<br>
<br>
<br>
</body>
</html>

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


Mime
View raw message