2 Replies Latest reply on Apr 1, 2009 4:25 PM by Shervin Asgari

    Raising Asynchronous events doesnt work

    Shervin Asgari Master

      I have created a system-log handler that listens on events. When these events occur it logs some stuff. However, when calling these events asynchronously it never gets called, but when I change it to a normal Event.raiseEvent call, it works fine.


      Why is that? I really want it to be asynchronously called.
      Anybody else experienced this?

        • 1. Re: Raising Asynchronous events doesnt work
          Shervin Asgari Master

          Small update here.
          It seems the event IS called, however it doesnt persist.



          Events.instance().raiseAsynchronousEvent("storeSystemlog", 
                                   Messages.instance().get("admin.userAdded").replaceAll("#0", currentUser.getUsername()), 
                                   Messages.instance().get("security"), 
                                   (adminLoggedIn != null ? adminLoggedIn.getUsername() : ""));




          @Observer("storeSystemlog")
              public void saveSystemlog(String description, String category, String username) {
                   SystemLog syslog = new SystemLog();
                   syslog.setCategory( (category == null ? "" : category) );
                   syslog.setDescription((description == null ? "" : description));
                   syslog.setDate(new Date());
                   syslog.setUsername((username == null ? "" : username));
                   
                   entityManager.persist(syslog);
              }


          • 2. Re: Raising Asynchronous events doesnt work
            Shervin Asgari Master

            Last update:
            I found the error. It was because my entityManager was not transactional because of the component being a JavaBean :-(


            @Transactional seemed to do the trick