views:

214

answers:

1

I am building a socketserver using Apache Mina and I am trying to make sense of configuring the thread model. I am currently reading:

http://mina.apache.org/configuring-thread-model.html

As I understand it; it is best to use multithreading for each IOService, something like:

SocketAcceptor acceptor = new SocketAcceptor( 
    Runtime.getRuntime().availableProcessors() + 1, 
    Executors.newCachedThreadPool()
);

I also understand it is best to use multiple threads to service events in the filter chain:

SocketAcceptor acceptor = ...;
DefaultIoFilterChainBuilder filterChainBuilder = 
    acceptor.getDefaultConfig().getFilterChain();
filterChainBuilder.addLast("threadPool", 
    new ExecutorFilter(Executors.newCachedThreadPool())
);

Is this correct?

If so, is there a rule-of-thumb for the optimal number of threads to process events?

A: 

The solution I came up with was to use Mina 2.0 which manages multithreading itself - works perfectly.

SlappyTheFish