Apache camel ApacheCamel-协议缓冲区端点

Apache camel ApacheCamel-协议缓冲区端点,apache-camel,netty,protocol-buffers,Apache Camel,Netty,Protocol Buffers,我正在尝试创建一个camel端点,它侦听tcp端口以接收使用协议缓冲区编码的消息。[ 我试图使用netty打开tcp端口,但无法使其工作 我的骆驼路线生成器是: from("netty:tcp://localhost:9000?sync=false").to("direct:start"); from("direct:start").unmarshal(format) .to("log:protocolbuffers?level=D

我正在尝试创建一个camel端点,它侦听tcp端口以接收使用协议缓冲区编码的消息。[

我试图使用netty打开tcp端口,但无法使其工作

我的骆驼路线生成器是:

    from("netty:tcp://localhost:9000?sync=false").to("direct:start");
    from("direct:start").unmarshal(format)
                        .to("log:protocolbuffers?level=DEBUG")
                        .to("mock:result");

我已经尝试过<代码>文本行< /代码>代码,但是这只会导致错误<代码> CO.GoGoL.TyfBuff.ValueStudioBuffelExtExc:当解析协议消息时,输入意外地在一个字段中间结束。这可能意味着输入被截断或者嵌入的消息错误地报告它自己的长度。< /代码> /P> 我想我需要使用字节数组编解码器,而不是字符串,但我看不到一种方法。我想我可以编写一个自定义端点来实现这一点,但我不想。任何指针都将不胜感激

我使用以下代码将消息发送到camel端点:

public static void main(String[] args) {
        try {
            TestProtos.Person me = TestProtos.Person.newBuilder().setId(2).setName("Alan").build();
            //set up socket
            SocketChannel serverSocket;
            serverSocket = SocketChannel.open();
            serverSocket.socket()
                        .setReuseAddress(true);
            serverSocket.connect(new InetSocketAddress("127.0.0.1", 9000));
            serverSocket.configureBlocking(true);

            //create BAOS for protobuf
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            //mClientDetails is a protobuf message object, dump it to the BAOS
            me.writeDelimitedTo(baos);

            //copy the message to a bytebuffer
            ByteBuffer socketBuffer = ByteBuffer.wrap(baos.toByteArray());

            //keep sending until the buffer is empty
            while (socketBuffer.hasRemaining()) {
                serverSocket.write(socketBuffer);
            }
            serverSocket.close();
        } catch (Exception e) {
            System.out.println("error....");
        }
    }
}
我还使用一个文件端点运行了一个测试,该端点按预期工作 与:


发送的序列化信息有多大?很小,我的测试“消息”是9个字节。@AndrewBraithwaite你找到解决方案了吗?@lobo恐怕没有。
@Test
public void fileTest() throws Exception {
    TestProtos.Person me = TestProtos.Person.newBuilder().setId(2).setName("Chris").build();

    File file = new File("/tmp/test.txt");
    FileOutputStream out = new FileOutputStream(file);
    me.writeTo(out);

    out.close();
};