public class ConnectionWatchdog
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler
implements org.jboss.netty.util.TimerTask
ChannelHandler responsible for monitoring the channel and
reconnecting when the connection is lost.| Constructor and Description |
|---|
ConnectionWatchdog(org.jboss.netty.bootstrap.ClientBootstrap bootstrap,
org.jboss.netty.channel.group.ChannelGroup channels,
org.jboss.netty.util.Timer timer)
Create a new watchdog that adds to new connections to the supplied
ChannelGroup
and establishes a new Channel when disconnected, while reconnect is true. |
| Modifier and Type | Method and Description |
|---|---|
void |
channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent e) |
void |
channelConnected(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent e) |
void |
exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ExceptionEvent e) |
void |
run(org.jboss.netty.util.Timeout timeout)
Reconnect to the remote address that the closed channel was connected to.
|
void |
setReconnect(boolean reconnect) |
public ConnectionWatchdog(org.jboss.netty.bootstrap.ClientBootstrap bootstrap,
org.jboss.netty.channel.group.ChannelGroup channels,
org.jboss.netty.util.Timer timer)
ChannelGroup
and establishes a new Channel when disconnected, while reconnect is true.bootstrap - Configuration for new channels.channels - ChannelGroup to add new channels to.timer - Timer used for delayed reconnect.public void setReconnect(boolean reconnect)
public void channelConnected(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent e)
throws Exception
channelConnected in class org.jboss.netty.channel.SimpleChannelUpstreamHandlerExceptionpublic void channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent e)
throws Exception
channelClosed in class org.jboss.netty.channel.SimpleChannelUpstreamHandlerExceptionpublic void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ExceptionEvent e)
throws Exception
exceptionCaught in class org.jboss.netty.channel.SimpleChannelUpstreamHandlerExceptionpublic void run(org.jboss.netty.util.Timeout timeout)
throws Exception
ChannelPipeline with the same handler instances
contained in the old channel's pipeline.run in interface org.jboss.netty.util.TimerTasktimeout - Timer task handle.Exception - when reconnection fails.Copyright © 2025. All rights reserved.