Class ConnectionWatchdog

    • Constructor Detail

      • ConnectionWatchdog

        public ConnectionWatchdog​(Delay reconnectDelay,
                                  ClientOptions clientOptions,
                                  Bootstrap bootstrap,
                                  Timer timer,
                                  EventExecutorGroup reconnectWorkers,
                                  Mono<SocketAddress> socketAddressSupplier,
                                  ReconnectionListener reconnectionListener,
                                  ConnectionFacade connectionFacade,
                                  EventBus eventBus,
                                  Endpoint endpoint)
        Create a new watchdog that adds to new connections to the supplied ChannelGroup and establishes a new Channel when disconnected, while reconnect is true. The socketAddressSupplier can supply the reconnect address.
        Parameters:
        reconnectDelay - reconnect delay, must not be null
        clientOptions - client options for the current connection, must not be null
        bootstrap - Configuration for new channels, must not be null
        timer - Timer used for delayed reconnect, must not be null
        reconnectWorkers - executor group for reconnect tasks, must not be null
        socketAddressSupplier - the socket address supplier to obtain an address for reconnection, may be null
        reconnectionListener - the reconnection listener, must not be null
        connectionFacade - the connection facade, must not be null
        eventBus - Event bus to emit reconnect events.
        endpoint - must not be null
    • Method Detail

      • scheduleReconnect

        public void scheduleReconnect()
        Schedule reconnect if channel is not available/not active.
      • run

        public void run​(int attempt)
                 throws Exception
        Reconnect to the remote address that the closed channel was connected to. This creates a new ChannelPipeline with the same handler instances contained in the old channel's pipeline.
        Parameters:
        attempt - attempt counter
        Throws:
        Exception - when reconnection fails.
      • setListenOnChannelInactive

        public void setListenOnChannelInactive​(boolean listenOnChannelInactive)
        Enable event listener for disconnected events.
        Parameters:
        listenOnChannelInactive - true to listen for disconnected events.
      • isListenOnChannelInactive

        public boolean isListenOnChannelInactive()
      • setReconnectSuspended

        public void setReconnectSuspended​(boolean reconnectSuspended)
        Suspend reconnection temporarily. Reconnect suspension will interrupt reconnection attempts.
        Parameters:
        reconnectSuspended - true to suspend reconnection
      • isReconnectSuspended

        public boolean isReconnectSuspended()