Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IllegalStateException: The current thread cannot be blocked: vert.x-eventloop-thread-1

I am trying to use quarkus reactive api to fetch data from another hibernate reactive project. I am getting this error whenever i try to get data from my hibernate project. I've figured that the error occurs in methods where i've called another method as well.the error i am getting

code for quarkus api

@GET
@Path("/getEquipCls")
public Uni<List<Tuple>> getMethod() {
    return reactiveMethod();                
}

code for service class of hibernate reactive method

@Override
public Uni<List<Tuple>> reactiveMethod(params) {
    Long variable = methodForVariable.await().indefinitely();
    return reactiveMethod(variable);
}

I've tried @Blocking & @NonBlocking annotations but none of them worked. Any help would be greatly appreciated.

like image 490
Nabil Ansari Avatar asked Feb 06 '26 07:02

Nabil Ansari


1 Answers

It seems there is a bit of misunderstanding, Reactive is not the same as Mutiny. Returning Type Uni<> or Multi<> from your method is Mutiny. Which could be Reactive, but it's not always the case depending on what dependencies you added.

That said, I've seen that you call await().indefinitely(); which wait for result and then give the correct non Uni type.

Disclaimer: I'm not a Mutiny expert so i'll try to help as much as i can.

Maybe you should try with this :

return methodForVariable.onItem()
    .transform(variable -> reactiveMethod(variable))

instead of this :

Long variable = methodForVariable.await().indefinitely();
return reactiveMethod(variable);

I think your blocking problem comes from here, where you try to block thread to wait for async processing, and then call an async method with previously fetched value. The way i suggested always keep processing async, so it should do the trick.

For more, be sure to check Mutiny's documentation

like image 77
Jacouille Avatar answered Feb 08 '26 20:02

Jacouille