@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { super.decode(ctx, in, out); if (isHandShaked()) { // At this point Netty has replaced SNIHandler (formally this) with SSLHandler in the pipeline. // Now we need to add other handlers at the tail of the queue logger.debugf("Handshaked with hostname %s", hostname()); Optional<Route<SniRouteSource, HotRodServerRouteDestination>> route = routingTable.streamRoutes(SniRouteSource.class, HotRodServerRouteDestination.class) .filter(r -> r.getRouteSource().getSniHostName().equals(this.hostname())) .findAny(); HotRodServerRouteDestination routeDestination = route.orElseThrow(() -> logger.noRouteFound()).getRouteDesitnation(); ChannelInitializer<Channel> channelInitializer = routeDestination.getHotrodServer().getInitializer(); ctx.pipeline().addLast(channelInitializer); logger.debug("Replaced with route destination's handlers"); } }