1 Reply Latest reply on Jul 16, 2010 9:22 AM by alrubinger

    What makes a business method asynchronous?

    jaikiran

      ... other than the use of @Asynchronous annotation or it's xml equivalent. From what I see in the EJB3.1 Spec, Section 4.5.1:

       

      The @Asynchronous annotation is used to designate which business methods are asynchronous.
      
      ...
      Asynchronous methods can also be designated via the deployment descriptor.
      

       

       

      I do however see that in our async interceptor (which has to decide whether to spawn a new thread or continue in the current one), we additionally check for method return type to decide whether it's asynchronous:

       

      // Determine if asynchronous (either returns Future or has @Asynchronous)
            if (invocation.resolveAnnotation(Asynchronous.class) != null || actualMethod.getReturnType().equals(Future.class))

       

       

      Just wondering whether this is OK. The only side-effect that I can think of, with this implicit rule for asynchronous method, is the difference in transaction semantics for that method invocation.

        • 1. Re: What makes a business method asynchronous?
          alrubinger

          jaikiran pai wrote:

          Just wondering whether this is OK. The only side-effect that I can think of, with this implicit rule for asynchronous method, is the difference in transaction semantics for that method invocation.

          It's likely not OK.

           

          Also not OK is the fact that I'm checking the actual java.lang.reflect.Method (and ignoring the class-level) instead of going to metadata.  At the moment the interceptor is client-side and we've no access to the metadata.  All this has to change, but for now I've got hacks like this (noted with TODOs) just to get some baseline that the mechanism is generally working.

           

          S,

          ALR