Skip to content

Inbound vs Outbound Handlers

In the context of the Netty ChannelPipeline, Inbound and Outbound handlers represent the two primary directions of data flow and event processing within a network application^[600-developer__big-data__netty__netty-ChannelPipeline.md].

ChannelPipeline Architecture

A ChannelPipeline is automatically created when a new channel is established^[600-developer__big-data__netty__netty-ChannelPipeline.md]. It manages a list of channel handlers, which can be added or removed dynamically at runtime^[600-developer__big-data__netty__netty-ChannelPipeline.md]. The pipeline acts as a container where handlers are organized to intercept and handle I/O events, either incoming from the network (Inbound) or outgoing to the network (Outbound)^[600-developer__big-data__netty__netty-ChannelPipeline.md].

Handler Types

  • Inbound Handlers: These handlers process incoming I/O events, typically starting from Socket.read() operations^[600-developer__big-data__netty__netty-ChannelPipeline.md]. They are triggered by fireIN_EVT method calls passed through ChannelHandlerContext^[600-developer__big-data__netty__netty-ChannelPipeline.md].
  • Outbound Handlers: These handlers process outgoing I/O requests, typically culminating in Socket.write() operations^[600-developer__big-data__netty__netty-ChannelPipeline.md]. They are triggered by OUT_EVT method calls^[600-developer__big-data__netty__netty-ChannelPipeline.md].

Execution Order

The order in which handlers are added to the pipeline dictates their execution sequence, which differs significantly between inbound and outbound flows^[600-developer__big-data__netty__netty-ChannelPipeline.md].

  • Inbound Flow: Inbound events are processed starting from the "head" of the pipeline (the first handler added) and move "down" the chain^[600-developer__big-data__netty__netty-ChannelPipeline.md]. For example, if handlers are added in the order 1, 2, 3, 4, 5, an inbound event will trigger 1, then 2, and finally 5 (assuming only these are Inbound handlers)^[600-developer__big-data__netty__netty-ChannelPipeline.md].
  • Outbound Flow: Outbound events are processed starting from the "tail" of the pipeline (the last handler added) and move "up" the chain^[600-developer__big-data__netty__netty-ChannelPipeline.md]. Using the same order 1, 2, 3, 4, 5, an outbound event will trigger 5, then 4, and then 3 (assuming only these are Outbound handlers)^[600-developer__big-data__netty__netty-ChannelPipeline.md].

Sources

^[600-developer__big-data__netty__netty-ChannelPipeline.md]