users@glassfish.java.net

[gf-users] Re: Future get() method behavior

From: Reza Rahman <Reza.Rahman_at_oracle.com>
Date: Fri, 08 Aug 2014 08:05:27 -0400

Please share code snippets annotating/explaining the issue. It's really
hard to follow the description. Future.get will return as soon as there
is a value to be returned from the underlying @Asynchronous method and
should block until then, but no longer.

On 8/6/2014 2:53 PM, Dennis Gesker wrote:
> I have an EJB method (in an EJB module within my EAR) which calls
> several other @Asynchronous methods in other classes which of course
> return a Future.
>
> In the calling method I issue get() statements so that I can use the
> returned value in a calculation. Nothing fancy there.
>
> I've been running this routine from @Schedule (once per day) method
> with no issues. Runs quickly (about 20 min) and reliably and returns
> the correct result -- an integer of record counts.
>
> However, when I try to run this same routine from my web module
> (within the same EAR) from within an @ApplicationScoped bean the
> method that calls the @Asynchronous methods returns/completes
> _*before*_ the future.get() method called completes and returns a
> value. No exception is thrown.
>
> Shouldn't a Future.get() call just block/wait until its work is
> complete regardless of how its called? Is a different behavior to be
> expected when called from a web module? Perhaps some kind of implied
> timeout?
>
> I could use a hint.
>
> NetBeans 8 and JDK 1.8.0_11 and Glassfish 4.0.1 promoted build 10
> (July-29) on Win8.1 Pro 64
>
> Dennis