[undertow-dev] Who Needs JAX-RS...

peter royal peter.royal at pobox.com
Mon Aug 31 08:40:24 EDT 2015


 

You are blocking the IO thread in each of your handlers. 

When each handler is a class, you can do: 

if( exchange.isInIoThread()) { 

 exchange.dispatch(this); 

 return; 

} 

but since you are using lambda's, that won't work. In this case, you
might want to just pass a Runnable to exchange.dispatch() 

that will put you on a worker pool thread where it is safe to block on
the Await.result call. 

an alternate (but lacking the timeout option) method I use is to
leverage the JDK8 CompletableFuture and use .thenAccept / .exceptionally
to return the response when available. 

-pete 

On 2015-08-29 21:00, Steve Logue wrote: 

> Hi Folks, I'm definitely new to Undertow and super impressed with it. However the docs are a bit thin in regards to using the RoutingHandler and doing full async processing. May I ask for a quick check of my approach to using Undertow and trying not to block anywhere: 
> https://github.com/bitvector2/microservice2/blob/master/src/main/java/org/bitvector/microservice2/HttpActor.java [1] 
> 
> -STEVEl 
> 
> -- 
> 
> http://www.bitvector.org/ [2] 
> 
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev [3]

-- 
 (peter.royal|osi)@pobox.com - http://fotap.org/~osi [4]
 

Links:
------
[1]
https://github.com/bitvector2/microservice2/blob/master/src/main/java/org/bitvector/microservice2/HttpActor.java
[2] http://www.bitvector.org/
[3] https://lists.jboss.org/mailman/listinfo/undertow-dev
[4] http://fotap.org/~osi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20150831/56a13b61/attachment.html 


More information about the undertow-dev mailing list