10 Replies Latest reply on Oct 3, 2011 5:41 AM by jaikiran

    EJB Async

    paul.setzermann

      Hi,

       

      I tried the EJB Asynchronous annotation but it is not working!

      I thought 7.0.2 is supporting it.

      Maybe I am missing something!?

      Could someone give me a short example?

        • 1. Re: EJB Async
          wolfc

          https://github.com/jbossas/jboss-as/tree/7.0.2.Final/testsuite/integration/src/test/java/org/jboss/as/testsuite/integration/ejb/async/

           

          Can you be a bit more precise how it is not working for you?

          Do you get an exception?

          Is the invocation synchronous? If so, how did you verify?

          • 2. Re: EJB Async
            paul.setzermann

            The method is invoked synchronously.

            When I check the a4j:log it´s always waiting for the asynch method to complete.

            My code looks like this:

             

             

            ...
             <a4j:commandButton action="#{updateAdbBean.update()}" value="Start" execute="@form" />
            ...
            
            
            @ManagedBean
            @SessionScoped
            public class UpdateAdbBean implements Serializable {
            
                      private static final long serialVersionUID = 2778548975359198879L;
              ...
            
                      public void update() {
            
                           ...
            
                                          FillOrUpdateAdbManager fillOrUpdateAdbManager = lookup(FillOrUpdateAdbManager.class);
                                          System.out.println("BEFORE");
                                          fillOrUpdateAdbManager.fillOrUpdate(true, updateAdbView.getSource(), adbSpecies, progressBean);
                                          System.out.println("AFTER!!!");
                            ...
                      }
            }
            
            
            @Stateless
            @Asynchronous
            public class FillOrUpdateAdbManager {
            
              @Asynchronous
                      public void fillOrUpdate(boolean bUpdate, String source, ADBSpecies species, ProgressBean progressBean) {
            
                                try {
                                          TimeUnit.SECONDS.sleep(10);
                                } catch (InterruptedException e) {
                                          e.printStackTrace();
                                }
            
                      }
            
            }
            
            

             

            Thanks and Cheers,

            Paul

            • 3. Re: EJB Async
              jadtn

              Hi

              I ve same problem

               

              The code is synchronous, not asynchronous

               

               

               

              @Singleton

              @Asynchronous

              public class AsyncBean {

                  @Asynchronous 

                  public void ignoreResult(int a, int b) {

                            System.out.println("slepp...");

                            try {

                                            Thread.sleep(5000);

                                  } catch (InterruptedException e) {

                                            // TODO Auto-generated catch block

                                            e.printStackTrace();

                                  }

                            System.out.println("fin sleep");

                      // the client doesn't care what happens here

                  }

               

               

              }

              • 4. Re: EJB Async
                morphy

                jboss 7.0.2 supports only ejb 3.1 light which do not have the asynch call as you can see here http://www.theserverside.com/news/1321142/Part-Three-New-Features-in-EJB-31 (look at the table... Table 1: EJB and EJB Lite Feature Comparison)

                 

                look also here

                 

                https://docs.jboss.org/author/display/AS7/Getting+Started+Guide

                 

                where you can find the profile's stack both for specs and for jb 7.0.x

                 

                bye

                • 5. Re: EJB Async
                  paul.setzermann

                  Hey Riccardo,

                   

                  Thanks for your help, but why is this stated in the release information?

                   

                   

                  ANKÜNDIGUNG: AS 7.0.2.Final "Arc" released!

                  A month after 7.0.1.Final was released, we now have  7.0.2! The binary downloads are available here. 7.0.2 "Arc" is mainly a bug fix release but also brings some new features and improvments:

                  • JSF 2.1
                  • Async EJB support!!
                  • Resurrected -b option for command line binding
                  • SSO support
                  • JNDI memory footprint improvement
                  • Limited support for Hibernate 3.3

                   

                   

                  Cheers,

                  Paul

                  • 6. Re: EJB Async
                    wolfc

                    Can you add some println statements to both UpdateAdbBean.update and FillOrUpdateAdbManager.fillOrUpdate?

                    Specifically: System.err.println(Thread.currentThread());

                    also add: new Exception("here").printStackTrace(); to fillOrUpdate.

                     

                    It should show two different threads and a trace which is running in the asynchronous executor service.

                    • 7. Re: EJB Async
                      morphy

                      maybe a documental bug or in the RN or in the user guide... it's hard to think a bug in the specifications... they are specifications and they say no async call for ejb light...

                       

                      with the distribution you should have the *-preview.xml which is the full jee stack (as far as i've understood), so we can assume a bug in the user guide (no ejb light in the full stack but full ejb)

                       

                      so try with that standalone/domain configuration

                       

                      and share

                       

                      bye

                      • 8. Re: EJB Async
                        morphy

                        @Carlo

                         

                        Hi, are you telling us that the jboss implementation of ejb light supports async calls?

                        • 9. Re: EJB Async
                          wolfc

                          No, good catch.

                           

                          The default configuration is only lite enabled:

                          <subsystem xmlns="urn:jboss:domain:ejb3:1.1" lite="true">
                          

                          Which in turn does not have async support.

                           

                          Try:

                          $ ./standalone.sh --server-config standalone-preview.xml
                          
                          1 of 1 people found this helpful
                          • 10. Re: EJB Async
                            jaikiran

                            The announcement in this forum has now been edited to make it a bit more clear that the async EJB support is available in the standalone-preview configuration of "everything" distribution.