JBoss series seventy-two: jBPM 6 new functionality / features introduced (API level)

Outline

jBPM 6.0 has been released with the final end of last month, there is a great change compared with the jBPM 5, article from API programming point of view to speak briefly jBPM 6, related to this article include:

  • Two important interface
  • Health management
  • jBPM service injection (CDI)

Two important interface

The two most important interfaces jBPM 6 refers KieSession (ProcessRuntime) and TaskService.


KieSession is the interface to the most commonly used and engine interaction, a KieSession permit application and the engine create a iterative conversation, where the state of the session is kept across invocations. The reasoning process may be triggered multiple times for the same set of data. When the application finished using the session, dispose () method must be transported, so in order to free the resources and used memory.

Use examples of the implementation of business rules file KieSession:

KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession();

for( Object fact : facts ) {
kSession.insert( fact );
}
kSession.fireAllRules();
kSession.dispose();

Examples of the use of business process execution file KieSession:

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);
KnowledgeBase kbase = kbuilder.newKnowledgeBase();
KieSession kSession = kbase.newStatefulKnowledgeSession();
kSession.startProcess("com.sample.processid");
kSession.signalEvent("SomeEvent", null);
kSession.startProcess("com.sample.processid");
kSession.dispose();

ProcessRuntime is the highest level of abstraction interface is used to start the process, create a process (not start), the activation signal to cancel a process, get all process instances have been acquired session related WorkItemManager.


TaskService can be seen as a unified access point to provide both, used to get all TaskService service. (The Task Service Entry Point serves as facade of all the other services, providing a single entry point to access to all the services)

Health management

Running jBPM 6 state management (Runtime Manager) using a local KieSession, local TaskService, compared with jBPM 5, hides the complexity of the setup process.

Runtime Manager managing three types of session:

  • Singleton session
  • Session per request
  • Session per process instance

As exemplified by a session management process:

RuntimeManager manager = RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager(environment);
RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get(id));
KieSession ksession = runtime.getKieSession();

// do something here, e.g.
ksession.startProcess(“org.jbpm.hello”);

manager.disposeRuntimeEngine(engine);
manager.close();

jBPM service injection (CDI)

jBPM default. 6 mounted to the container JEE6 compatible JBoss 7, CDI is an essential component of JEE6, jBPM 6 also provides a related service jBPM CDI may be injected into the environment.

Registration RuntimeManager following example:

@Inject 
@Singleton 
RuntimeManager singletonManager;

Registered TaskService following example:

@Inject 
TaskService taskService;



Reproduced in: https: //my.oschina.net/iwuyang/blog/197155

Guess you like

Origin blog.csdn.net/weixin_33896726/article/details/91897426