Information Technology Reference
In-Depth Information
The KIE session
In contrast to the KieBase objects, KieSession objects store and execute all the
runtime data. They're represented in the kmodule.xml file by the ksession tag. They
can be created from KieBase or, as we saw in the The KIE container section, from the
KieContainer object directly. This object is the point of contact to start, signal, and
complete process instances:
KieSession namedKsession =
kcontainer.newKieSession("ksession1");
KieSession newKsession = kbase.newKieSession();
There is another flavor of KieSession called StatelessKieSession that can run
isolated one-time-use-and-dispose executions, but since they don't support process execu-
tions, we will skip them in this topic.
From the process's perspective, we are interested in the following methods that are exposed
by the KieSession interface:
public ProcessInstance startProcess(String processId);
public ProcessInstance startProcess(String processId,
Map<String, Object> params);
public void signalEvent(String type, Object event);
public void signalEvent(String type, Object event, Long
processInstanceId);
We will use these methods (and other services implemented with these methods) to interact
with our process instances at the runtime. You can see a quick example of these configura-
tions in the testKieAPIConfigurations method of the KieAPIProcessExecu-
tionTest class, as shown in the following code:
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
Kfs.write("src/main/resources/my-process.bpmn2",
getFile("my-process.bpmn2"));
kfs.generateAndWritePomXML(ks.newReleaseId(
"com.wordpress.marianbuenosayres", "test", "1.0"));
Search WWH ::




Custom Search