You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Artur Edward <ar...@gmail.com> on 2005/05/19 14:50:15 UTC

Problem with decode method and ByteBuffer size...

Hello !
  I have two question. First is how do I need to proceed, if my
"ProtocolDecoder" implementation's "decode" method is invoked with
"ByteBuffer in" totally filled, but containing for example five full
objects and part of the sixth ?
  I was thinking to keep this sixth element's part as session's
attachement and to look for it each time at the beginning of the
"decode" method. Is this approach reasonable ?
  I have found this problem when i was testing server's throughput
using "crazy" client which was requesting server in loop without any
delay.
  Other thing is that when i'm trying to change "ReceiveBufferSize" with 
"cfg.setSessionReceiveBufferSize( 4096);" in
"sessionOpened(ProtocolSession session)" method of my
"ProtocolHandlerAdapter" implementation :-)
it's to late because io layer is already receiving requests using
default buffer size. Is there a way to change this behaviour ? Or
maybe i am wrong...

Thanks a lot for help !

With best regards from Poland !
- Artur Zielazny

Re: Problem with decode method and ByteBuffer size...

Posted by Julien Vermillard <jv...@archean.fr>.
Le jeudi 19 mai 2005 à 14:50 +0200, Artur Edward a écrit :
> Hello !
>   I have two question. First is how do I need to proceed, if my
> "ProtocolDecoder" implementation's "decode" method is invoked with
> "ByteBuffer in" totally filled, but containing for example five full
> objects and part of the sixth ?
>   I was thinking to keep this sixth element's part as session's
> attachement and to look for it each time at the beginning of the
> "decode" method. Is this approach reasonable ?
look at CumulativeProtocolDecoder everything is there for do that :

loop for each message object you find and "write" it to the output.
If some chunk of message are remainning in the buffer, just return false
and the remaining bytes will be added to next Decoder call.

It's very convenient.

Julien