Additional Netty convenience classes and handlers
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

This library represents a small collection of netty utilities. These are mostly ideas and nothing is tested!


Strongly types message handlers and prevents the user from having to cast of check instanceof on individual messages. This results in cleaner, easier to understand handlers.

First declare a POJO, which implements the TypedMessageListener marker interface, and annotate methods you wish to handle specific messages with the Listen annotation.

public class MyMessageHandler implements TypedMessageListener {
  public void handleInteger(ChannelHandlerContext ctx, TypedMessageEvent<Integer> e) {

  public void handleFloat(ChannelHandlerContext ctx, TypedMessageEvent<Float> e) {


You then need to insert an instance of your POJO as an argument to the TypedMessageEventHandler in your pipeline. It's important to recognize that this handler will not parse messages for you, you must first handle framing and decoding.

pipeline.addLast("frameDecoder", new MyFrameDecoder());
pipeline.addLast("messageDecoder", new MyMessageDecoder());
pipeline.addLast("messageHandler", new TypedMessageEventHandler(new MyMessageHandler()));

My specific use case is one where I have a protocol made-up of many protobuf messages. In this case I use a length based frame decoder, a custom protobuf message decoder then handle indidual messages with a custom handler.


Adapts Channel to an OutputStream

final ChannelOutputStream channelOutputStream = new ChannelOutputStream(channel);