0
votes

Based on the documentation https://netty.io/4.1/api/io/netty/channel/ChannelPipeline.html:

// Tell the pipeline to run MyBusinessLogicHandler's event handler methods
// in a different thread than an I/O thread so that the I/O thread is not blocked by
// a time-consuming task.
// If your business logic is fully asynchronous or finished very quickly, you don't
// need to specify a group.
pipeline.addLast(group, "handler", new MyBusinessLogicHandler());

this should provide multithreading for the handler. But actually it doesn't, please check the implemented example: https://github.com/oleg-sta/NettyExample/blob/master/src/main/java/com/example/netty/Main.java In this example, HelloServerHandler receives messages one-by-one, why the workerGroup don't work?

1
Asked same question on github: github.com/netty/netty/issues/10352, the answer were provided as belowoleg-sta

1 Answers

1
votes

The reason for this is that most protocols need some sort of ordering which can't be guaranteed if we just pick a new thread for each message. That said you can archive what you want by using the UnorderedThreadPoolEventExecutor when adding a handler to the pipeline