the future returned to the caller can be cancelled, the future instance you
return can't since it is here just to match the returned type:
public Future<Foo> asyncMethod() {
return new Foo();
}
this is really what you do but it doesnt compile so you wrap Foo in an
AsyncResult to match java typing but if you debug it is not a AsyncResult
that the caller get but a real Future.
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>
2016-01-12 13:42 GMT+01:00 Leonardo K. Shikida <[email protected]>:
> Hi
>
> Is it possible to cancel a long-running @Asynchronous method?
>
> My idea was to cancel the Future object, but according to
>
> http://tomee.apache.org/examples-trunk/async-methods/README.html
>
> "Important to note that the AsyncResult object the JobProcessor returns is
> not the same Future object the caller is holding. It would have been neat
> if the real JobProcessor could just return String and the caller's version
> of JobProcessor could return Future<String>, but we didn't see any way to
> do that without adding more complexity. So the AsyncResult is a simple
> wrapper object. The container will pull the String out, throw the
> AsyncResult away, then put the String in the *real* Future that the caller
> is holding."
>
> This thread also indicates that it's not defined in the EJB spec
>
>
> http://stackoverflow.com/questions/16493381/cannot-cancel-asynchronous-call-to-ejb
>
> Any help is welcome.
>
> []
>
> Leo
>