Search code examples
micronautmicronaut-client

Micronaut's HttpClient: event-loop-group, num-of-threads, thread-factory: how do they work in conjunction?


I come from the Spring Framework and now I'm on a micronaut project. I know very little about netty and its concepts yet and with that I have a doubt that the micronaut documentation is not clear to me.

I'm in doubt about the settings below:

  • micronaut.http.client.event-loop-group
  • micronaut.http.client.num-of-threads
  • micronaut.http.client.thread-factory

I would like to understand:

  • Considering that it is possible to define the number of threads of an event-loop-group, does it make sense to configure an event-loop-group and ALSO client.num-of-threads / client.thread-factory?

  • If they can be used together: How do they work together?

  • If they cannot be used together: How do they differ? What is the most appropriate use case for each?


Solution

  • The num-of-threads and thread-factory options are only used if you create the client outside of the application context via HttpClient.create.

    The event-loop-group configuration is to tell the client to use a different event loop group than the default. Event loop groups can be configured through micronaut.netty.event-loops. See https://docs.micronaut.io/latest/guide/configurationreference.html#io.micronaut.http.netty.channel.DefaultEventLoopGroupConfiguration