I have an example that extends JbpmJUnitBaseTestCase to create Kiesession, let's name this example ExA.
In ExA, the process will be waiting for external event to continue and complete.
So I do startProcess(), signalEvent(), and getProcessInstances() in 3 different methods.
After startProcess(), the process is waiting for external signal and the state is active (1).
Then getProcessInstances() confirms that there is 1 undergoing process.
Finally, signalEvent() triggers the process to continue and its state becomes complete (2).
In ExA, I use the following code snippet to get KieSession to work with:
manager = createRuntimeManager(bpmfiles);
engine = getRuntimeEngine(null);
ksession = engine.getKieSession();
Then I decide to take persistence approach and not to extend JbpmJUnitBaseTestCase no more to run the example, let's call it ExB.
In ExB, I use the following code snippet to get KieSession:
ds = new PoolingDataSource();
KieServices kservices = KieServices.Factory.get();
KieStoreServices kstore = kservices.getStoreServices();
//Create an environment variable with all the database configuration content
Environment environment = kservices.newEnvironment();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
TransactionManager tm = TransactionManagerServices.getTransactionManager();
//KieSession configuration object to configure special components
KieSessionConfiguration ksconf = kservices.newKieSessionConfiguration();
//KieBase we will use to create and restore the runtime from the database
KieBase kbase = kservices.getKieClasspathContainer().getKieBase();
//Invocation to create a new persistent session
ksession = kstore.newKieSession(kbase, ksconf, environment);
After startProcess(), the process is waiting for external signal and the state is active (1), as expected.
However processinstancelog table is empty and getProcessInstances() returns null --> this is stange!
So I skip getProcessInstances() and run again.
Finally, signalEvent() triggers the process to continue, but its state stays in active (1) --> this is strange.
I attach PTest.java and BPMService.java for your reference.
PTest.java is the test code I run, and BPMService.java is the actual code to deal with the process.
I need your advise to sort out this problem, thank you.