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
>
> I think it's something related to multi-threads codec interaction, but I
> couldn't work it out.
> I wonder if there is something to take care when implementing a protocol
> codec in multi-threads.
> Actually there's not a lot of documentation and guidelines in
> multi-threads usage of mina framework and codec implementation.
> I don't know, I'm talking about some step by step examples.
>
> Any help and further discussion would be really appreciated..
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.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com