[jboss-user] [jBPM] - Map based persistence doubt

Christian Marmolejo do-not-reply at jboss.com
Mon Aug 27 03:28:13 EDT 2012

Christian Marmolejo [https://community.jboss.org/people/chrismarm] created the discussion

"Map based persistence doubt"

To view the discussion, visit: https://community.jboss.org/message/756068#756068

Hi everyone

In my current project I need to persist active processes on demand before application shutdown and reload them at a later time. For simplicity, persistence should use binary files to store serialized process and session information, so databases are not intended to be used. In this scenario I think that a map based persistence solution might be appropiate.

I have found very little info about jBPM persistence in general and even less about map based persistence, so I have tried to understand the test cases in source code with no success. I added a test case in MapPersistenceTest.java for a very simple process: Start --> Script --> EventNode --> Script --> EventNode --> Script --> End. Scripts are only used to print out some "debug" info. The code is (class MapBasedPersistenceTest.java has no changes):

    public void fullCustomTest()
        String processId = "com.telvent.prueba";
        String eventType = "PrimeraSenal";
        String eventType2 = "SegundaSenal";

        KnowledgeBase kbase = createKBase();
        StatefulKnowledgeSession crmPersistentSession = createSession(kbase);

        org.drools.runtime.process.ProcessInstance process = crmPersistentSession.startProcess(processId);
        long processInstanceId = process.getId();
        Assert.assertEquals(ProcessInstance.STATE_ACTIVE, process.getState()); 

        crmPersistentSession.signalEvent(eventType, null);
        process = crmPersistentSession.getProcessInstance(processInstanceId);

        int sessionId = crmPersistentSession.getId();
        StatefulKnowledgeSession crmPersistentSession2 = disposeAndReloadSession(crmPersistentSession, sessionId, kbase);
        crmPersistentSession2.signalEvent(eventType2, null); 

        process = crmPersistentSession2.getProcessInstance(processInstanceId);

    private KnowledgeBase createKBase()
        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
        kbuilder.add(ResourceFactory.newClassPathResource("com/telvent/SampleProcess.bpmn"), ResourceType.BPMN2);  
        KnowledgeBase kbase = kbuilder.newKnowledgeBase();
        return kbase;

After the first signalEvent, the second script is executed properly but after reloading the session and firing the second signal, I expected the last script to be fired and the process finished. However, the last script isn't reached and the second assert fails as the process still waits for the first signal, not the second one. Could anyone explain what I am doing wrong?

Thanks in advance

Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120827/a292d2e6/attachment.html 

More information about the jboss-user mailing list