[jbpm-dev] Help with Signal Start Event

Kris Verlaenen kverlaen at redhat.com
Mon May 16 22:12:25 EDT 2011


Thanks, this indeed seems to be an issue with dynamically loading this 
process to the knowledge base.
I've create a JIRA issue for this and will look at fixing this:
https://issues.jboss.org/browse/JBPM-3197

Kris

Federico Feller wrote:
> Hi All,
>
> I need some help with the signal start event of bpmn2
> It seems that the signal start event doesn't work  when a process 
> definition is added to a knowledge base of an already created session.
> I have slightly modified the testSignalStart() unit test 
> of SimpleBPMNProcessTest.java to reproduce the problem
> Firstly, I've added a new process definition 
> named BPMN2-SignalStart2.bpmn2, based on the 
> original BPMN2-SignalStart.bpmn2, just renaming the signal name from 
> MySignalStart to MySignalStart2 and renaming the process id from 
> Minimal to Minimal2
>
> The following test runs without any problem, since both process 
> definitions are added before the session is created
>
> public void testSignalStart() throws Exception {
>         KnowledgeBase kbase = 
> createKnowledgeBase("BPMN2-SignalStart.bpmn2");
>         KnowledgeBase kbase2 = 
> createKnowledgeBase("BPMN2-SignalStart2.bpmn2");
>         kbase.addKnowledgePackages(kbase2.getKnowledgePackages());
>         StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
> final List<Long> list = new ArrayList<Long>();
> ksession.addEventListener(new DefaultProcessEventListener() {
> public void afterProcessStarted(ProcessStartedEvent event) {
> list.add(event.getProcessInstance().getId());
> }
> });
> ksession.signalEvent("MyStartSignal", "NewValue");
>         ksession.signalEvent("MyStartSignal2", "NewValue");
> assertEquals(2, list.size());
>     }
>
> However, the following test fail to run, as the process Minimal2 is 
> never started when doing ksession.signalEvent("MyStartSignal2", 
> "NewValue");
> If I start the process directly using 
>  ksession.startProcess("Minimal2") then the test passes. 
>
>     public void testSignalStart2() throws Exception {
>         KnowledgeBase kbase = 
> createKnowledgeBase("BPMN2-SignalStart.bpmn2");
>         KnowledgeBase kbase2 = 
> createKnowledgeBase("BPMN2-SignalStart2.bpmn2");
>         
>         StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
>         
> ksession.getKnowledgeBase().addKnowledgePackages(kbase2.getKnowledgePackages());
> final List<Long> list = new ArrayList<Long>();
> ksession.addEventListener(new DefaultProcessEventListener() {
> public void afterProcessStarted(ProcessStartedEvent event) {
> list.add(event.getProcessInstance().getId());
> }
> });
> ksession.signalEvent("MyStartSignal", "NewValue");
>                 ksession.signalEvent("MyStartSignal2", "NewValue");
> //ksession.startProcess("Minimal2");
> assertEquals(2, list.size());
>     }
>
> I found some clues on why this is happening.
> The first test works because, when the session is created, the 
> method ProcessRuntimeImpl::initProcessEventListeners() is invoked, and 
> the event listeners are properly initialized
> But in the second test, the event listeners are not initialized since 
> adding a package does not reinitialize the session.
> Any ideas on where I can start looking to fix this? or any workaround?
>
>  Thanks!
>
> Federico
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> jbpm-dev mailing list
> jbpm-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jbpm-dev
>   


More information about the jbpm-dev mailing list