Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-2190

JBOSS 6M5, EJB 3.1 Asynchronous method not running Asynchronously

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • None
    • None

      Annotated EJB 3.1 @Asynchronous method not running asynchronously.

      Created simple Java EE project, depoyed to both glassfish 3.0.1 and jboss 6-M5.

      Glassfish appears to run asynchronously, jboss seems to block on the call and wait for the method to execute.

      Here is the simple code example:

      package com.syncme;

      import javax.ejb.Local;

      @Local
      public interface TestAsynchLocal {

      public void methodAsynchronous();
      public void methodNonAsynchronous();
      }

      package com.syncme;

      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javax.annotation.Resource;
      import javax.ejb.Asynchronous;
      import javax.ejb.SessionContext;
      import javax.ejb.Stateless;

      @Stateless
      public class TestAsynch implements TestAsynchLocal {

      @Resource
      SessionContext sctx;

      @Asynchronous
      public void methodAsynchronous() {
      try

      { System.out.println("methodAsynchronous starting"); Thread.sleep(10000); System.out.println("methodAsynchronous done"); }

      catch (InterruptedException ex)

      { Logger.getLogger(TestAsynch.class.getName()).log(Level.SEVERE, null, ex); }

      }

      public void methodNonAsynchronous()

      { System.out.println("methodNonAsynchronous starting"); TestAsynchLocal localAsynch = sctx.getBusinessObject(TestAsynchLocal.class); localAsynch.methodAsynchronous(); System.out.println("methodNonAsynchronous done"); }

      }

      Call from web:

      package com.wbean;

      import com.syncme.TestAsynchLocal;
      import javax.ejb.EJB;
      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.SessionScoped;

      @ManagedBean(name="jsfmanbean")
      @SessionScoped
      public class NewJSFManagedBean {
      @EJB
      private TestAsynchLocal testAsynch;

      /** Creates a new instance of NewJSFManagedBean */
      public NewJSFManagedBean() {
      }

      public String Next()

      { return "NEXT"; }

      public void RunLong()

      { testAsynch.methodNonAsynchronous(); }

      }

      Here are the outputs:

      Jboss 6M5 run:

      17:51:40,803 INFO [STDOUT] methodNonAsynchronous starting
      17:51:40,804 INFO [STDOUT] methodAsynchronous starting
      17:51:50,805 INFO [STDOUT] methodAsynchronous done
      17:51:50,805 INFO [STDOUT] methodNonAsynchronous done

      Glassfish 3.0.1 run:
      INFO: methodNonAsynchronous starting
      INFO: methodNonAsynchronous done
      INFO: methodAsynchronous starting
      INFO: methodAsynchronous done

            Unassigned Unassigned
            jblake20_jira Jamie Blake (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: