micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.03k stars 1.05k forks source link

Consider making @Blocking behave as @ExecuteOn(TaskExecutors.IO) #7239

Open sdelamo opened 2 years ago

sdelamo commented 2 years ago

Issue description

I think for Micronaut 4.0, if a user adds @Blocking to a method and they are using the Netty runtime the behaviour should be identical as if they use @ExecuteOn(TaskExecutors.IO).

I think @Blocking is a more idiomatic annotation which conveys what the codes does. Then it is up to the runtime to execute it in a different thread pool if applies.

We are already using @Blocking in Micronaut Data CRUD repositories

Currently, @Blocking only works for AUTO thread selection. Since Micronaut 2.0 thread section defaults to manual.

sdelamo commented 2 years ago

An alternative would be to remove @Blocking as suggested by @jameskleeh. An advantage to remove the annotation would be to have a single way of doing things.

jameskleeh commented 2 years ago

@Blocking requires the user to read the javadoc to know what thread it executes on but @ExecuteOn makes it clear immediately