Replies: 4 comments
-
While reactive types are still faster, with virtual threads the main disadvantages disappear, so yes we should remove that recommendation.
Blocking operations can still block the event loop. But if you use ExecuteOn or |
Beta Was this translation helpful? Give feedback.
-
Hi @yawkat, thanks for answering. Can you tell me if adding |
Beta Was this translation helpful? Give feedback.
-
I think you are misunderstanding what "blocking the event loop" means. It does not matter how you do the blocking, whether the client is annotated with ExecuteOn (which I believe does nothing anyway), or even whether you block in some completely different way that does not involve BlockingHttpClient. What matters is that the controller must not block at all when it runs on the event loop. So if you use blocking operations like BlockingHttpClient, you must make sure that the controller is annotated with ExecuteOn (or the equivalent config property). Then what you do in the controller doesn't matter. |
Beta Was this translation helpful? Give feedback.
-
Got it. In the app I'm currently working on, I'm not using a Controller. It's a cron job that uses virtual threads to run a bunch of tasks (calling an external service via HTTP and processing the response in the same unit of work, basically). From what you just shared; I believe I'm already covered, but feel free to correct me if I'm wrong. The only thing that I just did is to remove the Thanks a lot :) |
Beta Was this translation helpful? Give feedback.
-
Issue description
Hi there!
I have a doubt about the threading model of the HTTP clients (low-level and declarative).
The HTTP low-level client docs (scroll down to
Performing an HTTP GET
) mention that non-blocking reactive types should be preferred over non-reactive ones:And same thing happens in declarative HTTP client docs (you'll need to scroll down to find it):
I have been using the declarative HTTP client by default, and all my methods return non-reactive types (I return DTOs directly which, I assume, are blocking types).
I understand this is can impact performance and I would like to know if:
filter
method fromClientFilter
can be annotated with@ExecuteOn(TaskExecutors.BLOCKING)
.Another related question is about
@CircuitBreaker
. I couldn't find anything in the docs about how it works with HTTP 400 Bad Requests. What I can tell is that, to me, it doesn't make any sense to retry a Bad Request. This isn't documented and I would like to know if someone can clarify it,, but again, I'm not sure of the current behavior (I plan on creating a PoC, perhaps tomorrow).Here's a link to a PoC app I made that proves that@CircuitBreaker
does retry (at least) 400 Bad Requests: https://github.com/Nahuel92/poc-projects/tree/master/micronaut/micronaut-circuitbreaker-pocThanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions