1 Reply Latest reply on Jan 16, 2014 11:45 AM by Fer Gia

    Process Event listener : not able to register

    rdeveloper87 Newbie

      Hi,

       

      I am adding a process event listener to a process as follows:

       

      public KieSession createKnowledgeSession(

        String processName) {

        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

        kbuilder.add(ResourceFactory.newClassPathResource(processName), ResourceType.BPMN2);

        KnowledgeBase kbase = kbuilder.newKnowledgeBase();

        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        ksession.addEventListener(new SampleProcessEventListener());

        return ksession;

        }

       

      When i put my flow in debug mode , i do not traverse the afterProcessStarted method.

      Am i missing something while doing this.

      TIA

        • 1. Re: Process Event listener : not able to register
          Fer Gia Newbie

          Hi!

          You must to create a class that implements EventListenerProducer<ProcessEventListener> and anotate it with @Process like this:

           

          @Process
          public class ProcessEventProducer implements EventListenerProducer<ProcessEventListener> {
          
            @Inject
            private YourProcessEventListener listener;
          
            @Override
            public List<ProcessEventListener> getEventListeners(String identifier,  Map<String, Object> params) {
             List<ProcessEventListener> list = new ArrayList<ProcessEventListener>();
             list.add(listener);
             return list;
            }
          }
          

          And you must to use a InjectableRegisterableItemsFactory in your RuntimeEnvironmentBuilder

           

          Hope it helps!

          1 of 1 people found this helpful