mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Re: CumulativeProtocollHandler
Date Fri, 30 Mar 2012 07:46:17 GMT
Le 3/29/12 9:58 PM, mrwhy@arcor.de a écrit :
> Hi together,
> i´m trying to use the CumulativeProtocollHandler and it is working for the most time
> But sometimes there coming more bytes then my message has. So i´m decoding my message
and write the message to the messageReceive method and want to return true. But now there
is already a second message in the Buffer. A return true results in a Exception, that describes
that returning true is not allowed as long there Bytes left in the Buffer. So could somebody
tell me, what i could do?
The CumulativeProtocolDecoder tries to gather all the incoming bytes up 
to a point it has a complete message to decode. You configure it to tell 
it that it has receive a complete message. Now, on TCP, there is no 
guarantee whatsoever that you won't receive some more bytes. In this 
case, the remaining bytes are simply kept into a buffer waiting for some 
more bytes.

Returning true in your doDecode() implementatio is the right thing to 
do. The decode() method just expect you to do that.

One possible reason you get an exception is that you have flipped the 
buffer before returning true. Just consume the buffer, the 
CumulativeProtocolDecoder will manage the buffer.
> The next time my Decoder is called he decodes the message which is in Buffer from previous
"double" message and the current one is in the end of the buffer an would´nt be decoded.
You most certainly flip the buffer. Don't.

Emmanuel Lécharny

View raw message