Uni runSubscription on and Timeouts #52888
krezchikov42
started this conversation in
Community
Replies: 1 comment 8 replies
-
|
Why do you use reactive if you have a blocking database? Also, the ifNoItem starts when the subscription is received, which, in your case, is delayed by the scheduler queue and item emission. So, the code behaves correctly. To get it working, you should not block item emission (which runs on the subscription thread in your case). Using an emitter should fix it (it will require a bit of work, since in the emitter callback, you need to start your thread (instead of runOnSubscription) and emit the item when ready). |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello there! I am a little confused on how to create rest level timeouts when using quarkus-resteasy-reactive
This is a an example of a java class that I have. Instead of thread.sleep I have a blocking database call. Since it is blocking according to docs we use
runSubscriptionOn. However, I've noticed through testing that this does not actually make it so the whole response will timeout after 150 ms. If you send multiple requests to this endpoint, they will all pass. This is because the the.ifNoItem().after(Duration.ofMillis(150))starts it's timer from when it is subscribed to on thesingleThreadPool. So despite being in the queue for thesingleThreadPoolfor longer than 150ms the requests won't time out. However, I want it so that if any response takes longer than 150 ms then it should timeout. So if you sent 4 requests at the same time to this endpoint, the first one would make it, and the next 3 would time out. I want to make it so that if the request has been waiting in the executor queue for longer than 150ms then the response will timeout and it will not make a request to the DB.Notes, I have to use my own executor to limit the number of concurrent queries being made to the db.
I think I have a slight misunderstanding of how to use quarkus-rest and how to use it with blocking database calls. Should I not be returning a Uni from my resource?
I'm using quarkus 3.8.4 and quarkus-resteasy-reactive
Beta Was this translation helpful? Give feedback.
All reactions