synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hubert, Eric" <>
Subject Understanding asynchrounous request processing in Apache Synapse/Axis2/Http Core NIO
Date Sun, 20 Jul 2008 14:39:44 GMT
Hi devs,

we are facing an issue in Apache Synapse where HttpClientWorkers are in
the process of writing a response back to the client using
HttpCoreNIOSender.sendAsyncResponse(), but are then waiting at
org.apache.http.nio.util.SharedOutputBuffer.flushContent() to get
notified by someone...

I'd like to take this issue as a start to gather more knowledge about
the internal working of Apache Synapse and http core nio in general.
Could someone please point me to some documentation, which describes,
how the request/response processing is working. Please also consider my
limited background in asynchronous event processing. I started with a
presentation by Doug Lea about the reactor design pattern. I guess this
is a good starting point, but obviously this is not enough.

When looking at a threaddump I see the following special thread types in
Apache Synapse:
- ClientWorker
- HttpServerWorker
- HttpCoreNIOListener
- HttpCoreNIOSender
- I/O dispatcher
- http-<sslport>Monitor
- http-<sslport>Processor
- ContainerBackgroundProcessor
- Axis2 Task
- Thread-XX (currently unnamed StatisticsReporterThread) 
  (maybe the code could be changed to assign a name to that thread)

Now I would like to understand the responsibility of each of these
Threads and how the interact. Who is responsible to wake up whom and so
on. So any information which helps me to understand this is greatly

My current understanding is as follows:

Incoming request from clients are processed from the
HttpCoreNIOListener, which is the in Axis2 configured non blocking
transport receiver for the http transport.
When starting this Listener, it starts an IOReactor
(org.apache.http.impl.nio.reactor.DefaultListeningIOReactor)-Thread with
name HttpCoreNIOListener. The IO reactor listens at the configured http
port and dispatches to the ServerHandler (NHttpServiceHandler). The
actual request process work is than delegated to a ServerWorker-Thread
from the pool. The ServerWorker delegates the request processing to
Axis2, where a SOAP message is created and the request is sent to the
endpoint. Right now the Axis2 engine is a kind of black box to me. I'm
not to sure about the whole handler chain between AxisEngine.receive()
and AxisEngine.send(). I hope this is not necessary for the general
understanding of the flow.
A TransportSender (HttpCoreNIOSender.sendAsyncRequest()) is used to send
the constructed soap message over the wire. The connection is
established using an inner IOReactor-Thread
The request is streamed using a nio ContentOutputBuffer.

Now the service at the specified endpoint processes the requests and
sends back a reply.

The response is processed by the ClientWorker who delegates the response
processing to Axis2 (again the blackbox of AxisEngine.receive,
AxisEngine.send) and then the response shall be send back to the client
over the MessageFormatter which again uses some NIO buffer. Here we have
the trouble that the code in
org.apache.http.nio.util.SharedOutputBuffer.flushContent() is waiting
for some notification. Who is responsible for that notification? The
HttpCoreNIOSender.reactor? I couldn't find any useful API-doc on this.
I'm also looking for some httpcore-nio-4.0-beta1-sources.jar from any
Maven Repo to attach to my synapse-IDE project.

Does anybody know something about possible causes for not getting such a

I would be very helpful for any help and pointers to more documentation
to understand more about the nio stuff.

Ah, and who creates the I/O Dispatcher? Are this the IOReactors? And are
the I/O Dispatcher again IOReactors?

Thanks for your help!


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message