public final class EmbeddedChannel : Channel

EmbeddedChannel is a Channel implementation that does neither any actual IO nor has a proper eventing mechanism. The prime use-case for EmbeddedChannel is in unit tests when you want to feed the inbound events and check the outbound events manually.

Please remember to call finish() when you are no longer using this EmbeddedChannel.

To feed events through an EmbeddedChannel‘s ChannelPipeline use EmbeddedChannel.writeInbound which accepts data of any type. It will then forward that data through the ChannelPipeline and the subsequent ChannelInboundHandler will receive it through the usual channelRead event. The user is responsible for making sure the first ChannelInboundHandler expects data of that type.

EmbeddedChannel automatically collects arriving outbound data and makes it available one-by-one through readOutbound.


EmbeddedChannel is currently only compatible with EmbeddedEventLoops and cannot be used with SelectableEventLoops from for example MultiThreadedEventLoopGroup.


Unlike other Channels, EmbeddedChannel is not thread-safe. This is because it is intended to be run in the thread that instantiated it. Users are responsible for ensuring they never call into an EmbeddedChannel in an unsynchronized fashion. EmbeddedEventLoops notes also apply as EmbeddedChannel uses an EmbeddedEventLoop as its EventLoop.