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):

    @Test
    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);
        Assert.assertNotNull(process); 

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

        process = crmPersistentSession2.getProcessInstance(processInstanceId);
        Assert.assertNull(process);
    }

    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
[https://community.jboss.org/message/756068#756068]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to