You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Mark Webb <el...@gmail.com> on 2007/03/13 14:15:11 UTC

StreamIoHandler vs IoHandlerAdapter with HTTP

I was looking at the 2 HTTP examples in Mina1.1, and have always wondered
this:  Why, if at line 50 of
org.apache.mina.example.httpserver.stream.HttpProtocolHandler a comment says
"You *MUST* execute stream I/O logic in a separate thread." there is a
stream based HTTP server example?  Is this just for illustrative purposes
and not intended for production level systems?  Or does this comment not
hold true anymore?

Thanks

-- 
..Cheers
Mark

Re: StreamIoHandler vs IoHandlerAdapter with HTTP

Posted by Trustin Lee <tr...@gmail.com>.
Hi Mark,

On 3/13/07, Mark Webb <el...@gmail.com> wrote:
> I was looking at the 2 HTTP examples in Mina1.1, and have always wondered
> this:  Why, if at line 50 of
> org.apache.mina.example.httpserver.stream.HttpProtocolHandler a comment says
> "You *MUST* execute stream I/O logic in a separate thread." there is a
> stream based HTTP server example?  Is this just for illustrative purposes
> and not intended for production level systems?  Or does this comment not
> hold true anymore?

As you know, InputStream.read() is a blocking operation.  If you block
the current I/O processor thread (or the thread pool thread) by
calling read(), it's simply a dead lock because the I/O processor (or
the event dispatcher) can't perform any I/O operation when you wait
for data.  That's why you need to spawn a new thread or use a
different thread pool.

Moreover, I always recommend you not to use the StreamIoHandler.  Only
use it if you have inevitable backward compatibility issues.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6