5 Replies Latest reply on Apr 10, 2017 3:09 AM by prateek singh

    Task event listener

    Fer Gia Newbie

      Hi all!!

       

      I want to add a task event listener to make actions while task event occurs.

       

      I have this:

       

      @PersistenceUnit(unitName = "jbpm")
        private EntityManagerFactory emf;
      
      @Inject
      private BeanManager beanManager;
      
      @Produces
      @PerProcessInstance
      public RuntimeEnvironment produceEnvironment(EntityManagerFactory emf) {
        RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault()
        .entityManagerFactory(emf)
        .userGroupCallback(usergroupCallback)
        .registerableItemsFactory(InjectableRegisterableItemsFactory.getFactory(beanManager, AuditLoggerFactory.newJPAInstance(emf)))
        .addAsset(ResourceFactory.newClassPathResource("process.bpmn"), ResourceType.BPMN2).get();
        return environment;
      }
      

       

      I added a Event listener class like that:

       

      public class TaskEventListener implements TaskLifeCycleEventListener {
      
        public TaskEventListener(){
      
        }
      
        @Override
      public void afterTaskActivatedEvent(Task ti) {
        System.out.println("Activated");
      }
      
      
      @Override
      public void afterTaskClaimedEvent(Task ti) {
        System.out.println("claimed");
      
      
        }
      
      }
      .....
      }
      

       

       

      This never prints any messages in the console and the TaskEventListener methods are never executed.

       

      I try adding a

      @Produce
      public TaskEventListener buildTaskEventListener(){
           return new TaskEventListener();
      }
      

      but the result is the same...

      What Im missing?

      Thanks all!