mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Re: [MINA 3.0] write future
Date Tue, 06 Sep 2011 14:37:05 GMT
On 9/6/11 3:55 PM, Julien Vermillard wrote:
> Hi !
> actually in MINA 1.0&  2..0 there is something implemented with an
> ugly hack : the future returned by session.write(..)  and
> IoHandler#messageSent(..);
>
> The main problem is you usually write a pojo at the session level, and
> it's transformed into one or multiple bytebuffer by the chain of
> filters. So when the message is actually written at the socket level
> by the IoProcessor, it's in a (or more) bytebuffers. So you need to
> hide the original pjoo message somewhere (attached to the last
> ByteBuffer resulting of the transformation) for completing the write
> future and generating the messageSent event.
>
> My first question is : do we need the future on the session.write(..)
> ? I already made two calls, one with the future and one without (for
> saving memory because most of time we don't need it), but perhaps we
> can dump this feature ?

Having a Future in this case is really a good thing, as the message can 
take a lot of time before it's completely sent. Now, the problem is that 
in the middle of the chain, you lose the "message", so there is some bad 
hack that creates and writes an empty byte buffer after all the byte 
buffers containing data for the encoded message, just in order to detect 
when the message has been fully sent.

There may be better ways to detect that a message has been fully sent, 
even if it's spilt in many byte buffers, but this has to be discussed. 
We can sill have this empty byte buffer as a marker.

In any case, I do think that keeping the WriteFuture could not harm.

-- 
Regards,
Cordialement,
Emmanuel L├ęcharny
www.iktek.com


Mime
View raw message