I just found the answer from a co-worker.
For the object I want to serialize and send via
a Mina ByteBuffer. I have to use writeObject
in the writeExternal func instead of write.
public void writeExternal(ObjectOutput out) {
byte[] bs = data.getBytes();
// Works!
out.writeObject(bs);
// Fails! Always capped by 1024 bytes
//out.write(bs, 0, bs.length);
}
On 8/31/06, Trustin Lee <[EMAIL PROTECTED]> wrote:
Hi Paul,
On 9/1/06, Paul Chen <[EMAIL PROTECTED]> wrote:
>
> Hi, all,
>
> I found a weird problem in Mina here, your insights are highly
> appreciated.
>
> [1] When I reply with a ByteBuffer from an socket handler to a
> connector handler with a ByteBuffer, it went through just fine
> no matter what size the data is. (several Kbytes).
>
> [2] When I use the following, its size is always capped by 1024
> bytes, and there's no 2nd transmission. The remaining data
> is just not sent.
>
> Sender:
>
> MyPacket packet = new MyPacket();
> // ... fill data into the packet, it is externalizable
> ByteBuffer buf = ByteBuffer.allocate(8192);
> buf.putObject(packet);
> buf.flip();
> session.write(buf);
>
> Receiver: only the initial 1024 bytes are recved, the rest is lost, no
> 2nd transmission !
There's no difference in sending just a byte buffer and sending a byte
buffer which contains an object. It's just a byte buffer from the
viewpoint
of MINA. Could you give us the previous code when you were not using
ByteBuffer.putObject()? The source code of receiving application would
help
us, too. And let us know which version of MINA you are using.
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41 4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4 455E 1C62 A7DC 0255 ECA6