jBPM6 samples with RuntimeManager

jBPM6 introduces new module – jbpm-runtime-manager – that aims at significantly simplify management of:

  • KnowledgeBase (KieBase)
  • KnowledgeSession (KieSession)
Moreover it allows to use predefined strategies for handling knowledge sessions and its relation to process instance. By default jBPM6 comes with three strategies:
  • Singleton – single knowledge session that will execute all process instances
  • Per Request – every request (which is in fact call to getRuntimeEngine) will get new knowledge session
  • Per Process Instance – every process instance will have its dedicated knowledge session for the entire life time
To make use of the strategy it’s enough to create proper type of RuntimeManager. jBPM6 allows to obtain instance of the RuntimeManager in various ways, this article will provide hands on information on how it can be achieved. 
With jBPM6 a whole new way of building application has been provided – Context and Dependency Injection is now available for users to build application and bring the power of jBPM to next level. Obviously CDI is not the only way to make use of jBPM – the regular API based approach is still available and fully functional.

CDI integration

jBPM6 tooling (like jbpm console or kie-wb) is built on CDI and thanks to that set of services has been provided to ease the development for custom applications that are based on CDI. These services are bundled as part of jbpm-kie-services and provides compact solution to most of the required operations to put BPM into your application:
  • deployment service – deploys and undeploys units (kjars) into the process engine
  • runtime service – gives access to state of the process engine, like retrieve process definitions, process instances, history log, etc
  • bpmn2 data service – gives access to details of the process definition taken from BPMN2 xml
  • form provider service – gives access to forms for processes and tasks
So whenever custom application is built with CDI these services are recommended way to go to get most of the power of CDI and jBPM. Moreover it’s the safest way too as it is used in jBPM tooling so it got fair amount of testing to secure it does what is expected.
Using jbpm-kie-services is not a mandatory to be able to use jBPM6 in CDI environment but it does have some advantages:
– allow to maintain multiple RuntimeManagers within single execution environment
– allow independent deploy and undeploy of units (kjar) without server/application restart
– allow to select different strategies for different units
See jbpm-sample-cdi-services project for details.
while these are all appealing add-ons they are not always needed, especially if application requires only single RuntimeManager instance to be included in the application. If that’s the case we can let CDI container to create the RuntimeManager instance for us. That is considered second approach to CDI integration where only single instance of RuntimeManager is active and it’s managed completely by the CDI container. Application needs to provide environment that RuntimeManager will be based on. 
See jbpm-sample-cdi project for details.

API approach

Last but not least is the regular API based approach to jBPM6 and RuntimeManager. It expects to be built by the application and in fact provides all configuration options. Moreover this is the simplest way to extend the functionality of RuntimeManager that comes out of the box.
See jbpm-sample project for details.
This article is just an introduction to the way jBPM6 and RuntimeManager can be used. More detailed articles will follow to provide in-depth information on every option given here (cdi with services, pure cdi, api).
If you have any aspects that you would like to see in next articles (regarding runtime manager and CDI) just drop a comment here and I’ll do by best to include them.


Comments are closed.