jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] Spec's reference of EJB's @Asynchronous is incorrect

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 30 Jan 2013 17:32:17 +0100

I'm not sure I follow how the EJB async "fire-and-forget" nature relates to HTTP. All we are saying is that the HTTP response is returned on a different thread that the one received the request. Async EJBs is one way how to delegate request processing to another (managed) thread in a JEE container. It's essentially the same approach as with using executor service manually to delegate the request processing to another thread.

Marek

On Jan 30, 2013, at 4:21 PM, Bill Burke <bburke_at_redhat.com> wrote:

> EJB methods can only be async if they return 'void' or a Future.
>
> In 'master' GIT, the spec, section 8.3 breaks the contract of how EJB and @Asynchronous works. @Asynchronous 'void' methods are *fire-and-forget* methods and HTTP is not a fire-and-forget protocol. IMNSHO, this example should be removed and JAX-RS use with EJB @Asynchronous should be illegal.
>
> The only thing I could support is if you immediately returned 202, Accepted to the client and then continued on with the EJB invocation:
>
> @Stateless
> @Path("/root")
> public class MyEjbResource {
>
> @POST
> @Asynchronous
> public void doit() {
> do a bunch of stuff
> }
> }
>
>
> Invocation on doit() would immediately return a 202 response to the client. This would of course require some pretty deep integration with the EJB container as you would have to process parameter injections and return 202 before you invoked the method. I would rather you just made it illegal to use @Asynchronous.
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com