Emmanuel Lecharny wrote:
Hi,
On Wed, Feb 18, 2009 at 11:49 AM, Patrizio Munzi
<[email protected]> wrote:
Hi,
A few months ago I've implemented a TCP client/server application using
MINA 1.x.
My application was multi-thread using Multi-Thread model and it used to
work.
These days I was trying to move it from MINA 1.x to MINA 2.0.0-M4 in
order to understand if there was any performance improvement.
However, after all changes for backward incompatibility, I'm having a
lot of troubles with multi-thread execution.
I mean if I run it with a single thread it work well, instead in case of
multi-threads execution I have the following exception:
org.apache.mina.filter.codec.ProtocolDecoderException:
java.nio.BufferUnderflowException
The model has changed since 1.0. You have to inject an exectutor
filter in your chain :
((DefaultIoFilterChainBuilder)chain).addLast( "executor",
new ExecutorFilter( new OrderedThreadPoolExecutor( nbThreads ),
IoEventType.WRITE ) );
It's important that the executor is an orderedThreadPool.
Give it a try and don't hesitate to post again if you have some pb with it.
Is this documented any more thoroughly anywhere - even just in a mailing
list thread? I'd like to understand a bit more about the change and why
it needs to be done this way. (i.e., why it needs to be done as a
filter as opposed to passing a thread pool into say the NioProcessor,
why an ordered thread is needed, etc.)
Thanks,
DR