-
1. Re: how to launch any process in parallel
swiderski.maciej Nov 24, 2014 1:40 AM (in response to ivanice)use different threads to lunch the process instances. Just few thoughts on what ti keep in mind:
- create runtime manager before you use threads to start process instances
- don't use singleton runtime manager strategy as singleton will synchronize all executions which essentially means you will have then done in sequence
- make sure to always get runtime engine and dispose runtime engine in each thread with use of proper context
That will give you parallel execution of your process instances
HTH
-
2. Re: how to launch any process in parallel
ivanice Nov 24, 2014 4:53 AM (in response to swiderski.maciej)thanks for the response like even XD,
what kind of strategy I should use to have a simple launch of any process in parallel? are there any examples about it?
-
3. Re: how to launch any process in parallel
swiderski.maciej Nov 24, 2014 11:42 AM (in response to ivanice)most likely best would be to use per process instance
HTH
-
4. Re: how to launch any process in parallel
ivanice Nov 24, 2014 3:10 PM (in response to swiderski.maciej)I tried to change this code with singleton:
private static RuntimeManager createRuntimeManager(KieBase kbase) {
JBPMHelper.startH2Server();
JBPMHelper.setupDataSource();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");
RuntimeEnvironmentBuilder builder = RuntimeEnvironmentBuilder.Factory.get()
.newDefaultBuilder().entityManagerFactory(emf)
.knowledgeBase(kbase);
return RuntimeManagerFactory.Factory.get()
.newSingletonRuntimeManager(builder.get(), "com.sample:example:1.0");
}
I have changed .newSigletonRuntimeManager with newPerProcess....... but after this the console give me a error in getRuntimeEngine:
this.ks = KieServices.Factory.get();
this.kContainer = ks.getKieClasspathContainer();
this.kbase = kContainer.getKieBase("kbase");
this.manager = createRuntimeManager(kbase);
this.engine = manager.getRuntimeEngine(null);
this.ksession = engine.getKieSession();
this.taskService = engine.getTaskService();
this.logService = engine.getAuditLogService();
The log of error is:
SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
Exception in thread "main" java.lang.NullPointerException
at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.getRuntimeEngine(PerProcessInstanceRuntimeManager.java:94)
at com.sample.ProcessMain.<init>(ProcessMain.java:46)
at com.sample.Manager.main(Manager.java:8)
-
5. Re: how to launch any process in parallel
ivanice Nov 24, 2014 3:12 PM (in response to ivanice)is there a different way to use a PerProcess strategy?? any example??
-
6. Re: how to launch any process in parallel
swiderski.maciej Nov 25, 2014 3:27 AM (in response to ivanice)you cannot use null as context when retrieving RuntimeEngine - as name suggest you need to use ProcessInstanceIdContext instead. It has two options:
- empty - ProcessInstanceId.get() - when you start new process instance - meaning there is no context set yet - no process instance
- with process instance id - ProcessInstanceId.get(processInstanceId) - when there is given process instance already active that you want to work with.
See examples here.
HTH