如何使用Netty 3.8 ServerBootstrap(TCP)将消息从服务器写入IP/端口

如何使用Netty 3.8 ServerBootstrap(TCP)将消息从服务器写入IP/端口,tcp,apache-camel,netty,send,Tcp,Apache Camel,Netty,Send,我想将消息从服务器发送到IP/端口,但在写入通道时它不起作用。我不确定我做错了什么 private Channel channel; private void createConnection() { ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedTh

我想将消息从服务器发送到IP/端口,但在写入通道时它不起作用。我不确定我做错了什么

    private Channel channel;
    private void createConnection() {

    ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
    this.bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            return Channels.pipeline(new SimpleChannelHandler());
        }
    });
    bootstrap.setOption("localAddress", new InetSocketAddress("localhost", 0));
    bootstrap.setOption("reuseAddress", true);
    bootstrap.setOption("child.sendBufferSize", 65536);
    bootstrap.setOption("child.receiveBufferSize", 65536);
    bootstrap.setOption("child.tcpNoDelay", true);
    bootstrap.setOption("child.keepAlive", true);

    this.channel = bootstrap.bind();
}
我正在使用ApacheCamel编写一个组件。当我的组件处理时,我希望它向IP/端口发送消息

    public void send(Exchange exchange) {

    String ip = exchange.getIn().getHeader("ip", String.class);
    int port = exchange.getIn().getHeader("port", Integer.class);

    Object msg = exchange.getIn().getBody();
    InetSocketAddress inetSocketAddress = new InetSocketAddress(ip, port);

    this.channel.write(msg, inetSocketAddress);
}

我得到了一个“getUnsupportedOperationFuture”。我不确定我做错了什么。我使用的是Netty 3.8,我认为连接设置正确。有什么帮助吗

嗨!您是否从头开始编写camel组件?为什么不直接使用Apache Camel Netty4?你好您是否从头开始编写camel组件?为什么不直接使用Apache Camel Netty4?