[jBPM] - More precise jBPM process execution measurement?
by Huy Tran
Huy Tran [http://community.jboss.org/people/huytran] created the discussion
"More precise jBPM process execution measurement?"
To view the discussion, visit: http://community.jboss.org/message/611159#611159
--------------------------------------------------------------
Hello everyone,
I'm working on a study on existing open-source process runtime frameworks (such as jBPM, Apache ODE, etc.) wrt to flexibility, scalability, performance, and so on. With regard to jBPM execution time, I tried several examples such as the ones shown in [1] and [2]. The initial experiment settings is to create a process having a fixed number of tasks (ranging from 100 to 1000), then invoke *startProcessInstanceByKey()* or *startProcessInstance()* surrounded by *System.nanoTime()* in order to measure the process's execution time.
(1) long startTime = System.nanoTime();
(2) ProcessInstance instance = executionService.startProcessInstanceByKey("Sequence1000");
(3) double executionTime = (System.nanoTime() - startTime) * 1.0e-6;
The preliminary measurement results seem to be very promising (~20ms for 1000 empty sequential tasks). However, I'm wondering if this measure is precise because the invocation of *instance.isEnded()* right after line (2) returns *false* (i.e., the process has not finished yet). Could somebody please show me how to precisely measure the execution time of a jBPM process (without looking to the underlying database tables)? Is there any convenient mechanism like callback or thing like that?
I truly appreciate your helps.
Kind regards,
Huy
[1] http://processdevelopments.blogspot.com/2008/04/awsome-jbpm-performance-n... http://processdevelopments.blogspot.com/2008/04/awsome-jbpm-performance-n...
[2] http://www.jorambarrez.be/blog/2008/04/14/short-jbpm-performance-showdown http://www.jorambarrez.be/blog/2008/04/14/short-jbpm-performance-showdown
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/611159#611159]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
14 years, 10 months
[jBPM] - Re: How does a sub-process work?
by stellina_rosa
stellina_rosa [http://community.jboss.org/people/stellina_rosa] created the discussion
"Re: How does a sub-process work?"
To view the discussion, visit: http://community.jboss.org/message/610610#610610
--------------------------------------------------------------
Hi! I have another question about Sub-processes;
In the sub-process I store some objects in the ksession; I would like to use the object ksession of the sub-process in the main process; in what way can I pass a parameter from sub-process to the main process?
I thought to create 2 variables: one in the main process called ksession (and type org.drools.runtime.StatefulKnowledgeSession), and the other variable in the sub-process called ksessionInternal (type org.drools.runtime.StatefulKnowledgeSession); these 2 variables are the "parameter out mapping" of the node sub-process... is right?
the problem is: in what way can I pass the ksessionInternal to the ksession variable?
thank you very much!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/610610#610610]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
14 years, 10 months
[jBPM] - can not end subprocess in concurrent execution (jBPM4.4)
by Philipp Ossler
saig0 [http://community.jboss.org/people/saig0] created the discussion
"can not end subprocess in concurrent execution (jBPM4.4)"
To view the discussion, visit: http://community.jboss.org/message/561928#561928
--------------------------------------------------------------
Hi!
I have a problem with jBPM 4.4 when I try to end a subprocess instance in a concurrent execution.
This image show an example process:
http://community.jboss.org/servlet/JiveServlet/showImage/2-561928-7482/su... http://community.jboss.org/servlet/JiveServlet/downloadImage/2-561928-748...
The process should execute a subprocess and wait of a signal in the concurrent execution. When a signal arrive, an external activity behavior (end subprocess) should call that will end the subprocess and both executions will join.
I can run this process correct with jBPM 4.3 but when i try to run with jBPM 4.4 the follow JbpmExecution throw:
com.ecg.mts.pcc.exceptions.PccException: EXCEPTION_tried to send signal: null to execution with id: SimpleProcess.57.63
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager.tryToSendSignalToExecution(JbpmProcessInstanceManager.java:209)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager.sendSignalToActivity(JbpmProcessInstanceManager.java:191)
at com.ecg.mts.pcc.internal.jbpm.JbpmProcessInstanceManagerTest.testEndSubProcessInstanceInExternalActivity(JbpmProcessInstanceManagerTest.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at com.ecg.test.testcase.AbstractDbTestCase.run(AbstractDbTestCase.java:195)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.ecg.mts.pcc.exceptions.PccException: EXCEPTION_tried to delete processInstance with id: SimpleSubProcess.64
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager.endProcessInstanceById(JbpmProcessInstanceManager.java:91)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager$1.execute(JbpmProcessInstanceManager.java:107)
at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:40)
at org.jbpm.pvm.internal.processengine.ProcessEngineImpl.execute(ProcessEngineImpl.java:300)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmEngine.executeCommand(JbpmEngine.java:194)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager.endProcessInstanceByIdCascade(JbpmProcessInstanceManager.java:112)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager$1.execute(JbpmProcessInstanceManager.java:106)
at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:40)
at org.jbpm.pvm.internal.processengine.ProcessEngineImpl.execute(ProcessEngineImpl.java:300)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmEngine.executeCommand(JbpmEngine.java:194)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager.endProcessInstanceByIdCascade(JbpmProcessInstanceManager.java:112)
at com.ecg.mts.pcc.internal.jbpm.scenario.externalActivityBehaviour.EndSubProcess.execute(EndSubProcess.java:18)
at org.jbpm.pvm.internal.wire.usercode.UserCodeActivityBehaviour.execute(UserCodeActivityBehaviour.java:42)
at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60)
at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:672)
at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:632)
at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:430)
at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:61)
at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35)
at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:50)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56)
at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:89)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager.tryToSendSignalToExecution(JbpmProcessInstanceManager.java:205)
... 22 more
Caused by: org.jbpm.api.JbpmException: execution[SimpleProcess.57.62] has running subprocess: execution[SimpleSubProcess.64] in state remove
at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1086)
at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:424)
at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:412)
at org.jbpm.pvm.internal.model.ExecutionImpl.end(ExecutionImpl.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_189.end(ExecutionImpl_$$_javassist_189.java)
at org.jbpm.pvm.internal.cmd.EndProcessInstance.execute(EndProcessInstance.java:48)
at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:40)
at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.endProcessInstance(ExecutionServiceImpl.java:117)
at com.ecg.mts.pcc.internal.jbpm.control.jbpm.JbpmProcessInstanceManager.endProcessInstanceById(JbpmProcessInstanceManager.java:87)
... 50 more
org.jbpm.api.JbpmException: execution[SimpleProcess.57.62] has running subprocess: execution[SimpleSubProcess.64] in state remove
at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1086)
at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:424)
at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:412)
at org.jbpm.pvm.internal.model.ExecutionImpl.end(ExecutionImpl.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
at org.jbpm.pvm.internal.model.ExecutionImpl_$$_javassist_189.end(ExecutionImpl_$$_javassist_189.java)
at org.jbpm.pvm.internal.cmd.EndProcessInstance.execute(EndProcessInstance.java:48)
at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:40)
at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.endProcessInstance(ExecutionServiceImpl.java:117)
...
I tried to end the subprocess instance like this:
executionService.endProcessInstance(processInstanceId, "remove");
(processInstanceId is the id of the execution in activity 'subprocess')
I also tried to send a signal to this execution but it throw the same exception.
It seems that I have to end the subprocess instance first, so I tried something like that but it doesn't work and throw the exception.
public void endProcessInstanceByIdCascade(final String processInstanceId) {
Command<Object> command = new Command<Object>() {
public Object execute(Environment environment) throws Exception {
ProcessInstance processInstance = executionService.findProcessInstanceById(processInstanceId);
Execution subProcessInstance = processInstance.getSubProcessInstance();
if (subProcessInstance != null) endProcessInstanceByIdCascade(subProcessInstance.getId());
executionService.endProcessInstance(processInstanceId, "remove");
return null;
}
};
processEngine.execute(command);
}
Did I make something wrong or is this a bug in jBPM 4.4?
Thank you for help!
Phil
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/561928#561928]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
14 years, 10 months
[jBPM] - [jBPM4.4] custom activity has an end time before this activity is leaveds the activity
by saig0
saig0 [http://community.jboss.org/people/saig0] created the discussion
"[jBPM4.4] custom activity has an end time before this activity is leaveds the activity"
To view the discussion, visit: http://community.jboss.org/message/600020#600020
--------------------------------------------------------------
Hi,
I note that a custom activity has an end time before this activity is leaved.
process:
<?xml version="1.0" encoding="UTF-8"?>
<process name="HistoryServiceTest" xmlns="http://jbpm.org/4.4/jpdl">
<start name="start" g="77,144,48,48">
<transition to="custom-state" />
</start>
<custom name="custom-state" g="175,140,105,52" class="processes.classes.SimpleCustomState">
<transition to="end" />
</custom>
<end name="end" g="324,144,48,48" />
</process>
SimpleCustomState.java:
package processes.classes;
import java.util.Map;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.activity.ExternalActivityBehaviour;
public class SimpleCustomState implements ExternalActivityBehaviour
{
private static final long serialVersionUID = 1L;
public void execute(ActivityExecution execution) throws Exception {
execution.waitForSignal();
}
public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters)
throws Exception {
execution.takeDefaultTransition();
}
}
test:
package services;
import org.junit.Assert.*;
import java.util.Date;
import java.util.List;
import java.util.zip.ZipInputStream;
import org.jbpm.api.*;
import org.junit.*;
public class HistoryServiceTest
{
private HistoryService historyService;
private ExecutionService executionService;
private RepositoryService repositoryService;
@Before
public void setup() {
initEngine();
deployProcess();
}
public void initEngine() {
ProcessEngine processEngine = new Configuration().setResource("default.jbpm.cfg.xml")
.buildProcessEngine();
executionService = processEngine.getExecutionService();
historyService = processEngine.getHistoryService();
repositoryService = processEngine.getRepositoryService();
}
public void deployProcess() {
ZipInputStream zipInputStream = new ZipInputStream(getClass().getResourceAsStream("/jbpm.zip"));
repositoryService.createDeployment().addResourcesFromZipInputStream(zipInputStream).setName("test")
.setTimestamp(new Date().getTime()).deploy();
}
public String startProcess() {
ProcessInstance processInstance = executionService.startProcessInstanceByKey("HistoryServiceTest");
return processInstance.getId();
}
private boolean isRunning(String processInstanceId) {
ProcessInstance pi = executionService.findProcessInstanceById(processInstanceId);
return pi != null ? pi.isEnded() : false;
}
@Test
public void testHasEndDateForEndedCustomActivity() {
String processInstanceId = startProcess();
String activityName = "custom-state";
assertTrue(executionService.findProcessInstanceById(processInstanceId).isActive(activityName));
executionService.signalExecutionById(processInstanceId, "");
assertFalse(isRunning(processInstanceId));
HistoryActivityInstance historyActivityInstance = historyService.createHistoryActivityInstanceQuery()
.processInstanceId(processInstanceId).activityName(activityName).uniqueResult();
assertNotNull(historyActivityInstance.getEndTime());
}
@Test
public void testHasNoEndDateForActiveCustomActivity() {
String processInstanceId = startProcess();
String activityName = "custom-state";
assertTrue(executionService.findProcessInstanceById(processInstanceId).isActive(activityName));
List<HistoryActivityInstance> historyActivityInstances = historyService
.createHistoryActivityInstanceQuery().processInstanceId(processInstanceId)
.activityName(activityName).list();
if (!historyActivityInstances.isEmpty())
{
for (HistoryActivityInstance historyActivityInstance : historyActivityInstances)
assertNull(historyActivityInstance.getEndTime()); // this fail!
}
}
}
After I looking for a reason, I found something in class UserCodeActivityBehaviour:
public void execute(ActivityExecution execution) throws Exception {
ActivityBehaviour activityBehaviour = (ActivityBehaviour) customActivityReference.getObject(execution);
activityBehaviour.execute(execution);
((ExecutionImpl)execution).historyAutomatic();
}
This methode create a object of class HistoryActivityInstanceImpl and call:
public HistoryAutomaticInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution) {
super(historyProcessInstanceImpl, execution);
setEndTime(Clock.getTime());
}
Now I want to ask why this was not implemented like in class StateActivity?
And how to fix this bug?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/600020#600020]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
14 years, 10 months