-
1. how to resume process
kmwen Feb 18, 2011 3:04 PM (in response to kmwen)I define the fisrt process definition as following:
ProcessEngine processEngine = new Configuration().setResource("jbpm.cfg.xml").buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();
repositoryService.createDeployment().addResourceFromClasspath("testFragment.jpdl.xml").deploy();
executionService.startProcessInstanceByKey("testFragment");
The testFragment is as following;
<?xml version="1.0" encoding="UTF-8"?>
<process name="testFragment" xmlns="http://jbpm.org/4.4/jpdl">
<start g="48,134,48,48" name="start">
<transition name="to HelloWorld" to="HelloWorld" g="-87,-22"/>
</start>
<custom class="org.jbpm.testMigration.MyTest" g="359,196,92,52" name="Test">
<transition name="to end" to="end" g="-43,-22"/>
</custom>
<java class="org.jbpm.testMigration.HelloWorld" g="147,194,92,52" method="printHelloWorld" name="HelloWorld">
<transition name="to Test" to="Test" g="-45,-22"/>
</java>
<end g="554,146,48,48" name="end"/>
</process>in custom node i throw an exception und catch it in catch block
catch (Exception e) {
System.out.println("we need the exception handling");
activityExecution.waitForSignal();
ProcessEngine processEngine = new Configuration().setResource("jbpm.cfg.xml").buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
ExecutionService executionService = processEngine.getExecutionService();
executionService.signalExecutionById("testFragment");
}
when i execute testFragment, the following execption occurres:
exception in thread "main" org.jbpm.api.JbpmException: execution testFragment does not exist.
how can i resume the testFragment? pleas help
-
2. how to resume process
vmdocua Feb 19, 2011 4:39 AM (in response to kmwen)Hi km wen,
Out of curiosity why did you create two ProcessEngine instances there? First process lives/managed by process engine A (where testFragment.jpdl.xml definition deployed), while for signaling used another process engine B. It's possible to reuse the same process engine instance inside single JVM process.
Another issue is "signalExecutionById" parameter - "execution ID" is not process definition ID or key or similar. Search for "execution id" phrase in this document http://docs.jboss.com/jbpm/v4/userguide/html_single/ for better understanding.
--
Thanks,
Vadim.
-
3. how to resume process
kmwen Feb 19, 2011 6:14 AM (in response to vmdocua)hi, vadim
thx for anwser
because i want to use external exception handling to handle the exception, i create two process engine.
i changed the definition of test fragment as following:
private ProcessDefinition createSimpleFragmentDefinitionStart() {
ProcessDefinitionBuilder builder2 = ProcessDefinitionBuilder.startProcess("Second Definition");
builder2.startActivity(new StartActivity()).initial().transition("A1").endActivity();
builder2.startActivity("A1", new Display("A1")).transition("A").endActivity();
builder2.startActivity("A", new MyTest()).transition("B1").endActivity();
builder2.startActivity("B1", new Display("B1")).endActivity();
return builder2.endProcess();
}
ClientProcessInstance getInstance(){
ProcessDefinition pd = createSimpleFragmentDefinitionStart();
ClientProcessInstance pi = ((ProcessDefinitionImpl) pd).startProcessInstance();
return pi;
}
and then i start this test process:
public static void main(String[] args) throws NullPointerException{
TestExceptionHandling te = new TestExceptionHandling1();
te.createSimpleFragmentDefinitionStart();
te.getInstance();
}
i try to resume the test process in exception handling process, and back to the activity A, because activity A1 is complete. I think i should get the processInstance of test process and use executionService.signalProcessById() to resume, but it doesn't work.