如何使用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