User development,
A new message was posted in the thread "Problem retrieving running process
instance":
http://community.jboss.org/message/518913#518913
Author : Oliver Schneider
Profile :
http://community.jboss.org/people/Masipulami
Message:
--------------------------------------------------------------
Hello everybody,
I'm quite new to JBPM and am currently investigating on how to start a process with a
client application A, having it end up in a certain wait state and finally continuing this
process instance with a client application B which then of course has to receive the
correct process instance and send a signal to continue it.
Client Application A:
=======================================
package publications.eu.jbpm;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.jbpm.api.Configuration;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.TaskService;
public class PodlTest {
public static void main(String[] args) throws Exception {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("catnum", "CDNA12239ENC");
variables.put("filePath",
"C:\\temp\\10168_CDNA12239ENC_20080922232844.zip");
variables.put("version", new Integer(1));
SimpleDateFormat sdfToDate = new SimpleDateFormat("dd.MM.yyyy
HH:mm:ss");
Date receptionDate = sdfToDate.parse("05.01.2010 11:07:54");
variables.put("receptionDate", receptionDate);
ProcessEngine processEngine = new Configuration().buildProcessEngine();
RepositoryService repositoryService = processEngine
.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();
TaskService taskService = processEngine.getTaskService();
String deploymentID = repositoryService.createDeployment()
.addResourceFromClasspath("publications/eu/jbpm/podl.jpdl.xml")
.deploy();
ProcessInstance processInstance = executionService
.startProcessInstanceByKey("podl", variables,
"CDNA12239ENC");
String pID = processInstance.getId();
System.out.println("(before completeTask) processInstance : "
+ processInstance);
System.out.println("(before completeTask) processInstance getId : "
+ processInstance.getId());
System.out.println("(before completeTask) processInstance getState : "
+ processInstance.getState());
System.out.println("(before completeTask) processInstance isEnded : "
+ processInstance.isEnded());
}
}
=======================================
Client application B:
=======================================
package publications.eu.jbpm;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.jbpm.api.Configuration;
import org.jbpm.api.Execution;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.TaskService;
public class PodlClientTest {
public static void main(String[] args) throws Exception {
ProcessEngine processEngine = new Configuration().getProcessEngine();
RepositoryService repositoryService = processEngine
.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();
TaskService taskService = processEngine.getTaskService();
ProcessInstance runningInstance =
executionService.findProcessInstanceById("podl.CDNA12239ENC");
Execution executionInWaitRedelivery =
runningInstance.findActiveExecutionIn("wait_test");
executionService.signalExecutionById(executionInWaitRedelivery.getId());
}
}
=======================================
After executing the first application, I have a running instance which stopped in the wait
state (entries in table JBPM4_EXECUTION).
Unfortunately after starting the second client, I am not able to retrieve the previous
process instance.
executionService.findProcessInstanceById("podl.CDNA12239ENC"); returns null.
The problem I guess is that ProcessEngine processEngine = new
Configuration().getProcessEngine(); recreates all the schemas resulting in the loss of any
previously stored process data.
Could anyone please give me some advice on how to fix this?
Thank you very much in advance and
kind regards,
Oliver Schneider
--------------------------------------------------------------
To reply to this message visit the message page:
http://community.jboss.org/message/518913#518913