You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by 나해빈 <mo...@gmail.com> on 2007/02/16 01:58:50 UTC

I got a question regarding putting thread pool in the IoHandlerAdapter

Hi, happy korean new year~.

Well, what a wonderful framework mina is!
I really appreciate Trustin and other team members for developing such a
great framework.

Well, I got a question regarding putting thread pool in the
IoHandlerAdapter.
In the IoHandlerAdapter extended class (server handler), there is a biz
logic doing something with database in the messageReceived method.
So, I figured it would perform much better if i put thread pool in the
server handler since db process logic requires at least 30ms.


// init blocking queue
// init thread pool

public void messageReceived(IoSession session, Object message) {
  queue.add(new Work(session, message));
}

class Worker extends Thread {
public void run() {
   for( ; ; ) {
      Work work = (Work)queue.poll(...);
      // do time consuming stuffs
      if (response != null)
         work.session.write(response).join();
   }
} // end of run
} // end of worker class

heck, i thought it was gonna speed up a little, well, no. only 10 msg
process / sec. (with or w/o the pool, the same)
it is still taking 100ms per message. how can i speed up process in the
server handler? and is this correct approach to do this?
(BTW, I modified http server example and added this logic.)