public void outputChannel(WritableByteChannel channel) {
        this.outputChannel = new TransferableChannel() {

            @Override
            public boolean hasPendingWrites() {
                return false;
            }

            @Override
            public long transferFrom(FileChannel fileChannel, long position, long count) throws IOException {
                return fileChannel.transferTo(position, count, channel);
            }

            @Override
            public boolean isOpen() {
                return channel.isOpen();
            }

            @Override
            public void close() throws IOException {
                channel.close();
            }

            @Override
            public int write(ByteBuffer src) throws IOException {
                return channel.write(src);
            }

            @Override
            public long write(ByteBuffer[] srcs, int offset, int length) throws IOException {
                long result = 0;
                for (int i = offset; i < offset + length; ++i)
                    result += write(srcs[i]);
                return result;
            }

            @Override
            public long write(ByteBuffer[] srcs) throws IOException {
                return write(srcs, 0, srcs.length);
            }
        };
    }
Sets the output channel to which messages received on this server are echoed.
This is useful in tests where the clients sending the messages don't receive
the responses (eg. testing graceful close).
clients/src/test/java/org/apache/kafka/common/network/NioEchoServer.java