So the Micronaut docs tell us that Micronaut uses an event loop:
Micronaut framework is built on Netty which is designed around an Event loop model and non-blocking I/O. Micronaut executes code defined in @Controller beans in the same thread as the request thread (an Event Loop thread).
And further says
To use the
blocking
executor, simply mark e.g. a controller withExecuteOn
I'm looking for reasons that the given annotations might not work. I've tried both
@ExecuteOn(TaskExecutors.BLOCKING)
or
@ExecuteOn(TaskExecutors.IO)
but the thread used is still one of default-nioEventLoopGroup-2-3
, etc
I have a blocking operation to execute, and it is failing with the error
io.micronaut.http.client.exceptions.HttpClientException: You are trying to run a BlockingHttpClient operation on a netty event loop thread. This is a common cause for bugs: Event loops should never be blocked. You can either mark your controller as @ExecuteOn(TaskExecutors.BLOCKING), or use the reactive HTTP client to resolve this bug. There is also a configuration option to disable this check if you are certain a blocking operation is fine here.
Alternatively, if anyone knows where/what that last mentioned "configuration option` is to disable the check, that would also be useful.
So the Micronaut docs tell us that Micronaut uses an event loop:
Micronaut framework is built on Netty which is designed around an Event loop model and non-blocking I/O. Micronaut executes code defined in @Controller beans in the same thread as the request thread (an Event Loop thread).
And further says
To use the
blocking
executor, simply mark e.g. a controller withExecuteOn
I'm looking for reasons that the given annotations might not work. I've tried both
@ExecuteOn(TaskExecutors.BLOCKING)
or
@ExecuteOn(TaskExecutors.IO)
but the thread used is still one of default-nioEventLoopGroup-2-3
, etc
I have a blocking operation to execute, and it is failing with the error
io.micronaut.http.client.exceptions.HttpClientException: You are trying to run a BlockingHttpClient operation on a netty event loop thread. This is a common cause for bugs: Event loops should never be blocked. You can either mark your controller as @ExecuteOn(TaskExecutors.BLOCKING), or use the reactive HTTP client to resolve this bug. There is also a configuration option to disable this check if you are certain a blocking operation is fine here.
Alternatively, if anyone knows where/what that last mentioned "configuration option` is to disable the check, that would also be useful.
Share Improve this question asked Nov 18, 2024 at 15:51 StewartStewart 18.3k8 gold badges56 silver badges84 bronze badges1 Answer
Reset to default 2happens to me as well. It turned out it is because I am using suspend function such as
@ExecuteOn(TaskExecutors.BLOCKING)
suspend fun greet(): String