Search code examples
nettynio

Difference between handlerUpstream and sendUpstream in netty


I am new to NIO and Netty framework.

I am developing the sample HTTP server using netty so I can handle thousands of clients connection asynchronously. I have used multiple handlers for encoding, decoding, aggregating and many.

When message received event occurred at one handler, then I pass it to next handler and so on.

For passing an even I have used ctx.sendUpstream(e) //ctx-ChannelHandlerContext, e-event

But going through the source code of the netty, I came across the another method handleUpstream(ctx, e)

I have tried to debug the netty source code, I am really confused between the usage of the sendUpstream() and handleUpstream().

How they differ from each other?Which one I should use?


Solution

  • Right, Netty 3 uses ChannelUpstreamHandler.handleUpstream() to process incoming messages and ctx.sendUpstream() to pass messages further upstream. Netty 4 has other methods like ctx.fireChannelRead()