Thread Blocked Warning while using Fibers/comsat http client !

96 views
Skip to first unread message

Mahieddine Cherif

unread,
Oct 18, 2016, 8:08:42 PM10/18/16
to vert.x
Hi,
I have a little web app where i basically consume some rest services using comsat jersey http client (async) 

// consume my reset service
Future
<Response> future = client.target(....).async().post();
// wait for result
Response response = Sync.awaitEvent(t -> {
 
try {

     t
.handle(future.get());

 
} catch (Exception e) {

    t
.handle(null);

 
}
});


The problem is that i'm getting a thread block warning, is that normal ? isn't supposed to be non blocking and run outside the main loop ? 


PS : i don't have this problem anywhere else, i'm using Quasar and yes all my methods have @Suspended annotation


Thank you very much !


Kindly,

chermah


Tim Fox

unread,
Oct 19, 2016, 3:32:27 AM10/19/16
to vert.x
Assuming the Future is a standard JDK future class (I can't see the package name)...

Future.get() is a blocking call, see the javadoc:

chermah

unread,
Oct 19, 2016, 4:31:33 AM10/19/16
to vert.x
@Tim Fox
Yes it's the standard JDK future class but in the doc http://docs.paralleluniverse.co/comsat/, they say "Calling Future.get() would also just block the fiber and not any OS thread." so i assumed that it was not a blocking call.

How can i do to resolve this? i really need to make async call but get results in a sync manner without blocking the main thread, what's the best practice ?


Thank you !!

Kindly,
chermah

Jochen Mader

unread,
Oct 19, 2016, 5:59:46 AM10/19/16
to ve...@googlegroups.com
You won't get there with the java-Future.
Why aren't you using the Vertx-http-client?

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9f4379bd-c5f3-460b-9448-f4bd2639b88a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jochen Mader | Lead IT Consultant

codecentric AG | Elsenheimerstr. 55a | 80687 München | Deutschland
tel: +49 89 215486633 | fax: +49 89 215486699 | mobil: +49 152 51862390
www.codecentric.de | blog.codecentric.de | www.meettheexperts.de | www.more4fi.de

Sitz der Gesellschaft: Düsseldorf | HRB 63043 | Amtsgericht Düsseldorf
Vorstand: Michael Hochgürtel . Mirko Novakovic . Rainer Vehns
Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Klaus Jäger . Jürgen Schütz

Jochen Mader

unread,
Oct 19, 2016, 6:00:49 AM10/19/16
to ve...@googlegroups.com
Well, you can get there by using executeBlocking, but I'd check if the vertx-http-client (shich is non-blocking) works for your usecase.

chermah

unread,
Oct 19, 2016, 6:25:41 AM10/19/16
to vert.x
I was using vertx http client but i had too much issues with it and slow, its not a reliable component for consuming rest services, when we migrated to comsat jersey client we had like 50% gain in time and all our issues disappeared.

We also wanted to avoid callback nightmares this is why we choosed to use comsat, but executeBlocking use a callback right ? we wanted a workaround without any callback? is that possible

Thank you so much guys for your help !

Kindly,
chermah
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
--
Jochen Mader | Lead IT Consultant

codecentric AG | Elsenheimerstr. 55a | 80687 München | Deutschland
tel: +49 89 215486633 | fax: +49 89 215486699 | mobil: +49 152 51862390
www.codecentric.de | blog.codecentric.de | www.meettheexperts.de | www.more4fi.de

Sitz der Gesellschaft: Düsseldorf | HRB 63043 | Amtsgericht Düsseldorf
Vorstand: Michael Hochgürtel . Mirko Novakovic . Rainer Vehns
Aufsichtsrat: Patric Fedlmeier (Vorsitzender) . Klaus Jäger . Jürgen Schütz

Jochen Mader

unread,
Oct 19, 2016, 7:05:44 AM10/19/16
to ve...@googlegroups.com
Then take a look at WorkerVerticles.

To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Marek Schmidt

unread,
Oct 19, 2016, 7:38:23 AM10/19/16
to ve...@googlegroups.com, jems....@gmail.com
I haven't tried it personally, but comsat should perhaps work with
vertx-sync

You may need to SyncVerticle and properly run it with the quasar java
agent, see

http://vertx.io/docs/vertx-sync/java/


>
> Thank you very much !
>
>
> Kindly,
>
> chermah
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "vert.x" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to vertx+un...@googlegroups.com
> <mailto:vertx+un...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/vertx.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/vertx/c2311145-75dc-4b43-a63a-2ba4055725e5%40googlegroups.com
> <https://groups.google.com/d/msgid/vertx/c2311145-75dc-4b43-a63a-2ba4055725e5%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--
Marek Schmidt

Tim Fox

unread,
Oct 23, 2016, 4:53:19 AM10/23/16
to vert.x
Maybe ask on the quasar list?

Standard JDK future would certainly block on get()

ad...@cs.miami.edu

unread,
Oct 25, 2016, 2:27:30 AM10/25/16
to vert.x
> I was using vertx http client but i had too much issues with it and slow, its not a reliable component for consuming rest services, when we migrated to comsat jersey client ? > we had like 50% gain in time and all our issues disappeared.

The above does not sound right.  the Vertx http client always seemed pretty snappy.  I wonder if there is something simple in your use of vertx httpclient that can be fixed to improve the performance and reliability.  I have found it to be neither slow nor unreliable.

-Adam

Jez P

unread,
Oct 25, 2016, 4:32:22 AM10/25/16
to vert.x
Indeed, did you report that and provide more detail to the team? I'm sure they wouldn't want it to be unreliable or slow, quite the opposite in fact.
Reply all
Reply to author
Forward
0 new messages