Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does upstream and downstream handlers work in Netty?

Tags:

java

netty

I'm new to Netty and don't really understand the flow of handlers in it. What I want to know is the difference between the Upstream and Downstream handlers.

  • Why can't we intercept the message in downstream handlers as we do in upstream?
  • Do downstream and upstream mean the same as in normal terms?
like image 960
Pradeep Avatar asked Dec 10 '22 02:12

Pradeep


1 Answers

The difference is that one handles incoming (upstream) and the other outgoing (downstream). I think the event/message flow gets more clear after looking at the javadoc of ChannelPipeline.

I should also note that upstream events will only get triggered by the IO-Thread so there is no need to synchronize field access in there if you use a new ChannelUpstreamHandler per ChannelPipeline. Downstream events can be triggered by any thread, so access to fields needs to be synchronized.

like image 90
Norman Maurer Avatar answered Jan 09 '23 07:01

Norman Maurer