@Override protected void doStart() throws Exception { if (camelContext == null && threadFactory == null) { throw new IllegalArgumentException("Either CamelContext or ThreadFactory must be set on " + this); } startServerBootstrap(); }
@Override protected void doStop() throws Exception { stopServerBootstrap(); }
protected void doReconnectIfNeeded() throws Exception { if (channel == null || !channel.isActive()) { LOG.debug("ClientModeServerBootstrap re-connect to {}:{}", configuration.getHost(), configuration.getPort()); ChannelFuture connectFuture = clientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort())); channel = openChannel(connectFuture); } }
@Override public void run() { try { LOG.trace("Re-connecting to {} if needed", configuration.getAddress()); doReconnectIfNeeded(); } catch (Exception e) { LOG.warn("Error during re-connect to " + configuration.getAddress() + ". Will attempt again in " + configuration.getReconnectInterval() + " millis. This exception is ignored.", e); } } }, configuration.getReconnectInterval(), TimeUnit.MILLISECONDS);
scheduleReconnect(channelFuture); return null; } else {
@Override protected void doStart() throws Exception { super.doStart(); LOG.debug("Netty consumer binding to: {}", configuration.getAddress()); if (nettyServerBootstrapFactory == null) { // setup pipeline factory ServerInitializerFactory pipelineFactory; ServerInitializerFactory factory = configuration.getServerInitializerFactory(); if (factory != null) { pipelineFactory = factory.createPipelineFactory(this); } else { pipelineFactory = new DefaultServerInitializerFactory(this); } if (isTcp()) { if (configuration.isClientMode()) { nettyServerBootstrapFactory = new ClientModeTCPNettyServerBootstrapFactory(); } else { nettyServerBootstrapFactory = new SingleTCPNettyServerBootstrapFactory(); } } else { nettyServerBootstrapFactory = new SingleUDPNettyServerBootstrapFactory(); } nettyServerBootstrapFactory.init(context, configuration, pipelineFactory); } ServiceHelper.startServices(nettyServerBootstrapFactory); LOG.info("Netty consumer bound to: {}", configuration.getAddress()); }
channel = openChannel(channelFuture);