Apache Camel Netty4解码器

时间:2018-11-15 09:00:34

标签: java apache-camel netty

如何使用camel-netty4组件来处理原始字节而不是textLine?我尝试使用:

from("netty4:tcp://{{my.host}}:{{my.port}}?encoder=#myEncoder&decoder=#myDecoder&disconnect=true");

其中

class MyDecoder extends ByteToMessageDecoder {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        out.add(in.readBytes(in.readableBytes()));
        in.retain();
    }
}

但我收到:

Caused by: io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
    at io.netty.buffer.AbstractReferenceCountedByteBuf.release0(AbstractReferenceCountedByteBuf.java:100) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
    at io.netty.buffer.AbstractReferenceCountedByteBuf.release(AbstractReferenceCountedByteBuf.java:84) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
    at io.netty.util.ReferenceCountUtil.release(ReferenceCountUtil.java:88) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
    at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:109) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
    ... 12 common frames omitted

0 个答案:

没有答案