Graceful shutdown

"이희승 (Trustin Lee)" trustin at gmail.com
Mon Jun 20 11:40:19 EDT 2011


Liche wrote:
> Norman Maurer-2 wrote:
>> As far as I can tell this will not close it "immediately. It will just
>> close all channels in an async fashion. It calls Channel.close() which
>> in fact is async.
>
> True, but channel.close() also won't wait for the request to be processed
> and the reply to be sent, hence the locking I've put in (in the
> absence/ignorance of a better method).

The idiom in this case would be to write an empty buffer and add a 
listener that closes the connection:

   ch.write(ChannelBuffer.EMPTY_BUFFER).addListener(
       ChannelFutureListener.CLOSE);

HTH

-- 
Trustin Lee, http://gleamynode.net/



More information about the netty-users mailing list