How to set up a thread pool when netty needs to create multiple ChannelGroup

problem description

when broadcasting with the ChannelGroup packet of netty, if there are multiple groups, how should the EventExecutor in the parameter be set when initializing ChannelGroup? Is it a direct GlobalEventExecutor.INSTANCE to make all ChannelGroup share the same thing? Or is there another new for each group, which class should be used if you want to assign a different one to each group?

the environmental background of the problems and what methods you have tried

is writing an im application that wants to send different messages to different groups with a ChannelGroup corresponding to a group.
but there is no information about what to do when creating multiple ChannelGroup.
most of them are like this, just create one, and then broadcast it directly to all connections

.
 private static ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);

but what if there are multiple groups?
or is it something like the following to maintain the relationship between a group and a connection, and then manually traverse a group to write messages to all channel in it during the broadcast?

for(Channel ch:map.get(groupid)){
    ch.writeAndFlush(msg)
}



Aug.30,2021

The EventExecutor of

ChannelGroup is mainly used for asynchronous notification.

for example: ch.writeAndFlush (msg) is an asynchronous call, which returns a ChannelGroupFuture, immediately after the call. When the asynchronous operation is completed, EventExecutor is used to execute the Listener added in the ChannelGroupFuture.

so if you don't have a lot of callbacks in your program, and there are simple non-blocking calls in callbacks, GlobalEventExecutor.INSTANCE is good enough.

but in the Netty source code, there are a lot of Future that use this Executor, so I think I new one or take a

from my EventGroup every time I use it.
Menu