-
1. Re: Process instance migration problem
sebastian.s Apr 29, 2010 4:29 PM (in response to fragmenthandler)I don't understand the first "use case" as you call it. I think if you want help you'll be in the need to post the actual process definitions and a test case to demonstrate what you are trying to do.
-
2. Re: Process instance migration problem
rebody Apr 29, 2010 11:31 PM (in response to fragmenthandler)Hi Sergey,
I cannot reproduce your scenario, so I make a testcase and upload it to attach. Maybe you could use it to reproduce this problem for us.
Thank you.
-
jbpm4sample.zip 6.3 KB
-
-
3. Re: Process instance migration problem
fragmenthandler May 10, 2010 6:13 AM (in response to rebody)Thanks for the answers. But what I do is more complicated. I use DefaultMigrationHandler from external code. My definitions have the different names and the second has not migration tag. Here is my testcase that represent my use case (simplified):
public void testMigrateRunning()
{
deployJpdlClasspath("org/uni/stuttgart/iaas/fragments/test/a.jpdl.xml");ProcessInstance processInstance = executionService
.startProcessInstanceById("a-1");
assertTrue(processInstance.isActive("a"));String id = processInstance.getId();
processInstance = executionService.signalExecutionById(id);
assertTrue(processInstance.isActive("x"));deployJpdlClasspath("org/uni/stuttgart/iaas/fragments/test/b.jpdl.xml");
processInstance = executionService.signalExecutionById(id);
assertTrue(processInstance.isActive("b"));
processInstance = executionService.signalExecutionById(id);
assertTrue(processInstance.isEnded());
}public void testMigrateRunningIntern()
{
deployJpdlClasspath("org/uni/stuttgart/iaas/fragments/test/a.jpdl.xml");ProcessInstance processInstance = executionService
.startProcessInstanceById("a-1");
assertTrue(processInstance.isActive("a"));String id = processInstance.getId();
processInstance = executionService.signalExecutionById(id);
assertTrue(processInstance.isActive("x"));String deploymentId = deployJpdlClasspath("org/uni/stuttgart/iaas/fragments/test/c.jpdl.xml");
// Get new process definition
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(
deploymentId).uniqueResult();
assertTrue(processDefinition.getName().equalsIgnoreCase("c"));
// Migrate instance here
new DefaultMigrationHandler().migrateInstance(processDefinition, processInstance, new MigrationDescriptor());processInstance = executionService.signalExecutionById(id);
assertTrue(processInstance.isActive("b"));
processInstance = executionService.signalExecutionById(id);
assertTrue(processInstance.isEnded());
}The first test is ok, the second is failed.
jpdl definition a:
<?xml version="1.0" encoding="UTF-8"?>
<process name="a" xmlns="http://jbpm.org/4.3/jpdl">
<start g="11,99,48,48" name="s">
<transition to="a"/>
</start><state g="106,94,110,52" name="a">
<transition to="x"/>
</state><state g="279,176,110,52" name="x">
<transition to="e"/>
</state><end g="499,99,48,48" name="e"/>
</process>
jpdl definition b:
<?xml version="1.0" encoding="UTF-8"?>
<process name="a" xmlns="http://jbpm.org/4.3/jpdl">
<start g="11,99,48,48" name="s">
<transition to="a"/>
</start><state g="106,94,110,52" name="a">
<transition to="x"/>
</state><state g="234,185,110,52" name="x">
<transition to="b"/>
</state><state g="371,92,110,52" name="b">
<transition to="e"/>
</state><end g="549,92,48,48" name="e"/>
<migrate-instances/>
</process>jpdl definition c:
<?xml version="1.0" encoding="UTF-8"?>
<process name="c" xmlns="http://jbpm.org/4.3/jpdl">
<start g="11,99,48,48" name="s">
<transition to="a"/>
</start><state g="106,94,110,52" name="a">
<transition to="x"/>
</state><state g="234,185,110,52" name="x">
<transition to="b"/>
</state><state g="371,92,110,52" name="b">
<transition to="e"/>
</state><end g="549,92,48,48" name="e"/>
</process>
Any help would be appreciated.
-
4. Re: Process instance migration problem
rebody May 10, 2010 9:14 PM (in response to fragmenthandler)Hi Sergey,
After migrate processinstance to a new processDefinition, you should update the modifed processInstance to database. Otherwise database couldn't know the processInstance has changed. So it seems the migration operation has no effect.
You could use Command to do this:
processEngine.execute(new Command() {
public Object execute(Environment env) {
new DefaultMigrationHandler().migrateInstance(pd,
pi, new MigrationDescriptor());
env.get(Session.class).update(pi);
return null;
}
});I attached the testcase. Please have a try. Thank you.
-
jbpm4sample.zip 10.0 KB
-
-
5. Re: Process instance migration problem
fragmenthandler May 18, 2010 3:36 AM (in response to rebody)Thank you! It works.