Access written message from WriteCompletionEvent

"이희승 (Trustin Lee)" trustin at gmail.com
Thu Aug 26 01:15:32 EDT 2010


It's complicated when there is a codec in a pipeline.  What message
should WriteCompletionEvent contain if a handler is placed before the
codec.  What about after the codec?  To guarantee the correct and
unsurprising behavior, the WriteCompletionEvent should contain all
result of message transformation, regardless to say higher memory
consumption.

Anyway, if you want to get the written message on write completion, you
can use ChannelFutureListener:

    final MyMessage msg = ...;

    ch.write(msg).addListener(new ChannelFutureListener() {
        void operationComplete(...) {
            System.out.println("Written: " + msg);
        }
    });

HTH,
Trustin

On 08/13/2010 10:56 PM, Sai Pullabhotla wrote:
> Is there a good reason why the WriteCompletionEvent does not provide
> access to the message that was written? I did see the JIRA case at
> https://jira.jboss.org/browse/NETTY-118. It said that the handler
> implementation becomes complicated. I'm not sure how complicated it
> would be, but for ease of use of the API, it would be nice to have the
> message available. This is especially useful for logging purposes to
> log only those messages that were actually sent.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 293 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100826/a221aa99/attachment.bin 


More information about the netty-users mailing list