0

I have a channel which needs to stay open because a lot of messages get written and I don't want to do a SSL-Handshake for every write.

If I would do this:

ChannelFuture future = channel.writeAndFlush(message1);
channel.writeAndFlush(message2);
future.addListener(new ChannelFutureListener(){

    @Override
    public void operationComplete(ChannelFuture channelFuture) throws Exception{

       //check for success   
    }
});

channel.writeAndFlush(message3);

is the assumption correct, that operationComplete will only be invoked for message1 but never for message2 nor message3?

pma
  • 860
  • 1
  • 9
  • 26
  • Not in TCP, because there are no messages in TCP. – user207421 Mar 04 '15 at 08:51
  • According the accepted answer to [this](http://stackoverflow.com/questions/18580181/when-does-a-netty-channelfuture-for-a-write-operation-become-done?rq=1) and the linked source `ChannelOutboundBuffer`indeed creates an `Entry`containing the given message and the associated future. – pma Mar 04 '15 at 13:19
  • There is nothing in that answer about messages. It's about completed *write* operations. – user207421 Mar 05 '15 at 06:08
  • Nitpicking much? From the answer I linked: "...after the given message was written to the socket". Besides: What exactly would be written other than the parameter named "message"? The term is used in the Netty-API and you knew exactly what I meant. – pma Mar 05 '15 at 10:28
  • TCP doesn't have messages, it has a byte stream. Any use of 'message' in association with TCP cannot be correct. – user207421 Mar 06 '15 at 00:03

1 Answers1

1

The ChannelFutureListener will only be executed for the ChannelFuture that was returned by a write. Each write will return another one. So yes.

Norman Maurer
  • 23,104
  • 2
  • 33
  • 31