【发布时间】:2013-02-11 04:46:00
【问题描述】:
使用 Netty 4.0.0.Beta1,将传入/传出 HTTP 流量记录到基于 netty 的服务器的最佳方式是什么?我的管道目前是:
p.addLast("decoder", new HttpRequestDecoder());
p.addLast("aggregator", new HttpObjectAggregator(1048576));
p.addLast("encoder", new HttpResponseEncoder());
p.addLast("handler", new MyBusinessLogicHandler());
我尝试编写一个实现ChannelInboundMessageHandler<FullHttpRequest> 的处理程序,然后在inboundBufferUpdated(ChannelHandlerContext ctx) 方法中进行日志记录,这对于传入的请求似乎工作正常,但这是推荐的方式吗?
当我尝试实现 ChannelOutboundMessageHandler<FullHttpResponse> 时,我没有成功地看到 flush(ChannelHandlerContext ctx, ChannelPromise promise) 方法中的实际 FullHttpResponse 对象。
建议?谢谢!
【问题讨论】:
-
所以我或多或少地发现我在放置日志处理程序的位置上有一个简单的问题。我仍在实施
ChannelInboundMessageHandler<FullHttpRequest>和ChannelOutboundMessageHandler<FullHttpResponse>。这是最好的方法吗? -
是的,这是最好的方法。
标签: netty