1 Reply Latest reply on Dec 9, 2014 2:04 AM by swiderski.maciej

    PerProcessInstance RuntimeManager event handler retention

    jolix71

      I'm using the 6.1.0.FINAL version. I create the runtimemanager via this:

      managerFactory.newPerProcessInstanceRuntimeManager(environment);

       

      I then get the runtime engine, create the ksession, add an event handler, and start a process.

       

      The event handler adding is like:  ksession.addEventListener(new DefaultProcessEventListener() { ...}

       

      I noticed that periodically (apparently when nodes are left but I could be wrong on the timing) the session (evidently recreated from a JPA store) object is renewed while keeping the same session id. It is here where any event listeners I add whether before or after starting the process are wiped out.

       

      Is this by design? are there workarounds to ensure that the event listeners added are kept?

       

      Thanks.

        • 1. Re: PerProcessInstance RuntimeManager event handler retention
          swiderski.maciej

          yes, this is by design. When you create RuntimeEnvironment instance you can give it an implementation of RegisterableItemsFactory that is responsible for delivering listeners, handler, etc whenever ksession is created which essentially frees you up from doing any manual registration. So either extend existing ones or provide your own implementation that will provide all the listeners you need.

           

          Usually good practice is to extend the default one (DefaultRegisterableItemsFactory) as it already registers some listeners that are quite important.

           

          Alternatively if you use kjars and jbpm 6.1 or above then you can use deployment descriptors. See docs for more details about both approaches.

           

          HTH