1 Reply Latest reply on Aug 20, 2010 12:47 AM by michel.ing

    Asynchronous not working on POJO

    agmkam

      Hi


      I am using Seam-Version: 2.2.0.GA with ice faces 1.8.i am trying to invoke a method asynchronously on POJO which is in conversation scope.


      Below is the code i am using


      @Asynchronous
      public void asyncMethod(AsyncParams p){
      }


      Everytime i call this method it is executed synchronously.


      Also I tried with the following entries in components.xml
      First try: core:dispatcher


      Second try: async:quartz-dispatcher


      still method is not executing in background.


      Please help.








        • 1. Re: Asynchronous not working on POJO

          Be sure that the method that you excute with @Asyncronous is in another class that is injected where the method is called x ej :


          @Name(emailService)
          @AutoCreate
          public class EmailService {


                  @In



                  private Renderer renderer;


                  @Asynchronous
                  public void sendMessageUser(@Duration long delay, String template,
                                  User user, String str) {
                          try {
                                  Contexts.getEventContext().set(info, user);
                                  Contexts.getEventContext().set(myPassword, str);
                                  renderer.render(template);
                          } catch (Exception e) {
                                  e.printStackTrace();
                          }
                  }



          this is called from another class:
                        
                          loggerAsync.saveLogBook(new Date(),
                                          UtilDate.cronFormat(cal1.getTime()), cal2.getTime(), bit,
                                          identity.getCredentials().getUsername());
                  }
          and works :)