首页 > 解决方案 > 写作时是否可以跳过多个ChannelHandler?

问题描述

我试图在我的写入管道中跳过多个 ChannelHandler,以便发送一个小的调试 ByteBuf。我知道您可以根据对象在同一管道中开发多个路径,但为此我只想在管道的最后快速转储此 ByteBuf。例如:

管道(输出):
Base -> Encoder -> Batcher -> Encrypter -> Frame length appender

所以我想从 Base 一直到我的 Frame length appender。

标签: javanetty

解决方案


你可以这样做,但我真的不推荐它。最好让您ChannelHandler根据消息类型做正确的事情。

这就是说这样的事情会做到这一点:

ChannelHandler context = channel.pipeline().context(Encrypter.class);
context.write(msg);

推荐阅读