1
我評估新的Netty 4.0,並試圖瞭解我需要做什麼從3.5移到新版本。 我有對夫婦querstion約potring到了Netty 4.0.0移動到新版本3.5
Netty中4.0.0的方法的messageReceived與inboundBufferUpdated方法代替。 用戶將一個或多個消息排入入站(或出站)緩衝區並觸發inboundBufferUpdated(或flush)事件。
此方法意味着在處理程序的執行位於用戶線程中時,入站(或出站)緩衝區的同步。 你可以建議另一種方式來發送沒有同步對象的收費(或出站)消息,例如,通過messageReceived方法在Netty 3.5中發送消息。在Netty 3.5中,我們使用SimpleChannelHandler,它提供了兩種事件類型的方法。我如何在Netty 4.0.0中使用相同的方法?
感謝您的答案。 我有很多時間處理這個文檔,並看到了這些例子,但仍然沒有解決這些問題。 如果我有多個處理程序被添加到管道中,在發生fireInboundBufferUpdated事件後 將調用第一個處理程序的inboundBufferUpdated方法。 – 2012-08-16 08:40:19
public void inboundBufferUpdated(ChannelHandlerContext ctx){if(ctx.hasInboundByteBuffer()){ByteBuf in_buf = ctx.inboundByteBuffer(); 隊列 out = ctx.nextinboundMessageBuffer(); ... out.add(new MyMsg(in_buf)); } else { \t隊列 in = ctx.inboundMessageBuffer(); 隊列 out = ctx.nextinboundMessageBuffer(); (;;){ MyMyMsg msg = in.poll(); if(buf == null) break; ... out.add(msg); } } ctx.fireInboundBufferUpdated(); } –
2012-08-16 08:43:07
帶有隊列(poll,add)的所有操作都是同步的,並且可能會影響系統的性能。 你可以建議另一種方式通過Fire InboundBufferUpdated事件傳遞消息到下一個處理程序嗎? – 2012-08-16 08:43:44