Class WriteTimeoutHandler

java.lang.Object
org.jboss.netty.channel.SimpleChannelDownstreamHandler
org.jboss.netty.handler.timeout.WriteTimeoutHandler
All Implemented Interfaces:
ChannelDownstreamHandler, ChannelHandler, ExternalResourceReleasable

@Sharable public class WriteTimeoutHandler extends SimpleChannelDownstreamHandler implements ExternalResourceReleasable
Raises a WriteTimeoutException when no data was written within a certain period of time.
 public class MyPipelineFactory implements ChannelPipelineFactory {

     private final Timer timer;

     public MyPipelineFactory(Timer timer) {
         this.timer = timer;
     }

     public ChannelPipeline getPipeline() {
         // An example configuration that implements 30-second write timeout:
         return Channels.pipeline(
             new WriteTimeoutHandler(timer, 30), // timer must be shared.
             new MyHandler());
     }
 }

 ServerBootstrap bootstrap = ...;
 Timer timer = new HashedWheelTimer();
 ...
 bootstrap.setPipelineFactory(new MyPipelineFactory(timer));
 
The Timer which was specified when the ReadTimeoutHandler is created should be stopped manually by calling releaseExternalResources() or Timer.stop() when your application shuts down.
See Also: