13 Replies Latest reply on Apr 12, 2011 8:14 AM by Michael

    Weld 1.1 in GFv3.1 and asynchronous methods

    Jan De Cooman Newbie
      Hi,

      In GFv3.1 I marked a method being asynchronous:

      @Inject
      @JobEvent
      private Event<String> jobActor;
      ...

      @Asynchronous
      @PermitAll
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      public void doImport(
      ....
      this.jobManager.fire(uuidJob);
      }


      On the observer side I have:


      public void finishJob(
      @JobEvent
      @Observes(notifyObserver = Reception.ALWAYS,
      during = TransactionPhase.AFTER_SUCCESS)
      final String uuid) {
      ....
      }

      I also have a method to handle the FAIL event.

      Now, this code functioned properly in GFv3.0.1 and with an older Weld. The import job was running async and when the job was finished or failed, the observer was called to set a flag.

      In GFv3.1 with Weld 1.1 I get the following error message:

      WELD-000401 Failure while notifying an observer of event ....

      Anyway, the problem is the @Asynchronous annotation. When I remove this annotation, then the code functions, but of course, block the import-thread. On the other hand, when I keep the @Asynchronous annotation and remove the "during=AFTER_SUCCES", then the code also function, but with a false outcome of course.

      What happened to Weld to have this behaviour? Is this a bug, or is this wanted? Does this imply that Weld does NOT work with Asynchronous methods anymore?

      Greetings,
      Jan