1 Reply Latest reply on Mar 13, 2014 3:47 PM by newohybat

    signalEvent doesn't trigger intermediate event node

    newohybat

      Hello,

      I have encountered a problem while working with events.

      I have a process, in which there is an intermediate catching event for an event of type "turn-new". Then in jbpm test case I start the process and then signal an event to it. The first event is caught, but any others are not. I checked that the process is still in active state. It seems to me, like the listener was removed with first signal, or something like that.

       

      I start the process via a drools rule, so in test case I just insert necessary facts to fire the rule, this rule then starts process and I get its id throught ksession.getProcessInstances(). Then I signal events by ksession.signalEvent("turn-new",null).

       

      There is a code snippet from the test case:

      ksession.insert(unitType);

      FactHandle cityHandle = ksession.insert(city);

      List<ProcessInstance> processes = (List<ProcessInstance>)ksession.getProcessInstances();

       

      ArgumentCaptor<AfterActivationFiredEvent> aafe = ArgumentCaptor.forClass( AfterActivationFiredEvent.class );

      verify( ael ,atLeastOnce()).afterActivationFired( aafe.capture() );

       

      List<String> firedRules = getFiredRules(aafe.getAllValues());     // get names of rules fired

       

      Assert.assertTrue(firedRules.contains("City Start Build Unit"));     // rule which starts the process

       

      Assert.assertTrue("One Process Should Be Active",processes.size()==1);

      WorkflowProcessInstance p = (WorkflowProcessInstance)processes.get(0);

       

      ksession.signalEvent("turn-new", null);

      assertProcessInstanceActive(p.getId(), ksession);

       

      city.setResourcesSurplus(60);     // alter city variable which is process variable within the process

      ksession.update(cityHandle, city);

       

      ksession.signalEvent("turn-new", null);

      assertProcessInstanceActive(p.getId(), ksession);

       

      city.setResourcesSurplus(60);

      ksession.update(cityHandle, city);

       

      ksession.signalEvent("turn-new", null);

       

      assertProcessInstanceActive(p.getId(), ksession);     // this one should fail, but passes

       

      assertProcessInstanceCompleted(p.getId(), ksession);     // this one should pass, but fails

       

      Process diagram:

      buildunit.png

      In the Process Turn node I event write a hello message to check whether the node is triggered (together with registering an event listener), but nothing writes out.

       

      Would it be problem of time interval between the events, or there happens something else?

       

      Thanks for help

      Jan

        • 1. Re: signalEvent doesn't trigger intermediate event node
          newohybat

          Oh my,

          sorry for such silly question.

           

          For those who didn't notice as well. The intermediate event in my case gets triggered only!! when the process flow is just before the event node, that means: after first run, the focus is already further in the flow and thus the intermediate event could not be fired.

           

          Jan