6 Replies Latest reply on Nov 18, 2011 2:23 PM by Julien Kronegg

    @Asynchronous EJB 3.1 AS7

    Vlad Tepes Newbie

      Hello

      Invoking methods with @Asynchronous annotation  does not work with JBoss 7. In JBoss 6 you can invoke method asynchronously, but you can't cancel it. In AS7 the method isn't even invoked asynchronusly, also it can't be canceled. You get an Exception when you try to. I'm running standalone-prewiev.

       

      Will @Asynchronous ever be supported?

       

      I'm just asking because it's a very cool feature and it's quite useful for me.

        • 1. Re: @Asynchronous EJB 3.1 AS7
          jaikiran pai Master

          It's not available in 7.0 but will be available in upcoming AS7 releases.

          • 2. Re: @Asynchronous EJB 3.1 AS7
            iran zhou Newbie

            any detail plan? thxxxx

            • 3. Re: @Asynchronous EJB 3.1 AS7
              jaikiran pai Master

              It's already there in 7.0.2 which has been released a while back.

              • 4. Re: @Asynchronous EJB 3.1 AS7
                iran zhou Newbie

                Some of my colleagues using Jboss 7.0.1

                NOW, it is ok!

                 

                thxxx

                • 5. Re: @Asynchronous EJB 3.1 AS7
                  Julien Kronegg Novice

                  Hi Jaikiran,

                   

                  I tested a simple asynchronous EJB under Jboss AS 7.0.2.Final Arc, and it does not work (the asynchronous method waits for 5 seconds synchronously):

                   

                  {code}

                  20:36:16,815 INFO  [stdout] (http--127.0.0.1-8080-1) request: begin Wed Nov 16 20:36:16 CET 2011

                  20:36:16,831 INFO  [stdout] (http--127.0.0.1-8080-1) doAsyncStuff: begin Wed Nov 16 20:36:16 CET 2011

                  20:36:21,832 INFO  [stdout] (http--127.0.0.1-8080-1) doAsyncStuff: end Wed Nov 16 20:36:21 CET 2011

                  20:36:21,834 INFO  [stdout] (http--127.0.0.1-8080-1) request: end Wed Nov 16 20:36:21 CET 2011

                  {code}

                   

                  My EJB is :

                   

                   

                  {code}

                  @Stateless

                  public class MyAsyncService {

                      @Asynchronous

                      public void doAsyncStuff() {

                          System.out.println("doAsyncStuff: begin "+ new Date());

                          try {

                              Thread.sleep(5000);

                          } catch (InterruptedException e) {

                              System.out.println("doAsyncStuff: interrupted");

                          }

                          System.out.println("doAsyncStuff: end "+ new Date());

                      }

                  }

                  {code}

                   

                  My servlet is :

                   

                   

                  {code}

                  @WebServlet("/MyServlet")

                  public class MyServlet extends HttpServlet {

                       

                      @EJB

                      MyAsyncService myAsyncService;

                   

                     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

                          System.out.println("request: begin "+new Date());

                         

                          myAsyncService.doAsyncStuff();

                        

                          System.out.println("request: end "+new Date());

                      }

                  }

                  {code}

                   

                  Is this code supposed to work under 7.0.2?

                  • 6. Re: @Asynchronous EJB 3.1 AS7
                    Julien Kronegg Novice

                    I found the solution: the server was configured with Web Profile (i.e. no asynchronous behavior) and not with the Full Profile.

                    I ran the server (7.0.2) with the following program argument in the Eclipse's server launch configuration:

                    {code}-server-config standalone-preview.xml{code}

                    JBoss AS 7.1 will merge the standalone and standalone-preview configuration.