jBPM5 application quickstart using Maven

jBPM5 offers a powerful open source BPM engine that you may want to implement in your company to address users needs such as business workflows, rules and events (if you want to understand jBPM5 a little bit more check out this introductory post). You may be wondering: how do I start?

If you are a Maven user, you are used to create POM file that describe your project and let Maven take care about dependencies and the build process. This post aims to give you an initial POM to use in your own projects and start building jBPM5 applications faster.

Creating our jBPM5 application POM

First, you need to have a jBPM5 distribution installed in your local Maven repository. In order to have it you need to follow these steps first.

Once you have the jBPM5 jars inside the local repo you can use your favorite IDE to create a Maven project POM and add the following dependencies (given that you build the jBPM5 yourself following the previous link):

<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-human-task</artifactId>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-persistence-jpa</artifactId>
<version>5.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bam</artifactId>
<version>5.0-SNAPSHOT</version>
</dependency>

As you may notice, I added the SNAPSHOT version so you can have the latest code. If you want to try a more stable version, change it to 5.0-CR1. However you’ll have to checkout the 5.0-CR1 branch from the repository, build and install it yourself.

With this little bit of Maven magic, we can now create a small HelloWorld test class to instanciate a process and see that everything is working as planned. You can download the POM and the Java test classes from the Plugtree’s GITHUB server.

Saying Hello to our Process World

After you download the sources, you can inspect the HelloWorldTest source. Inside the source code you will notice a readKnowledgeBase method that sets up several factories in order to jBPM5 to be active inside the Drools Sessions:

ProcessBuilderFactory
.setProcessBuilderFactoryService(new ProcessBuilderFactoryServiceImpl());

ProcessMarshallerFactory
.setProcessMarshallerFactoryService(new ProcessMarshallerFactoryServiceImpl());

ProcessRuntimeFactory
.setProcessRuntimeFactoryService(new ProcessRuntimeFactoryServiceImpl());

BPMN2ProcessFactory
.setBPMN2ProcessProvider(new BPMN2ProcessProviderImpl());

If we don’t configure these factories Drools will try to use its internal process engine (Drools Flow). In the latest version of Drools this is not necessary, as it will autodetect the presence of jBPM5 and configure itself accordingly. However as the jBPM5 distribution is configured to use Drools 5.2.0-alpha1 and not the Drools SNAPSHOT, this is not done automagically.

There’s another bunch of configuring to do:

properties.put(“drools.processInstanceManagerFactory”,
DefaultProcessInstanceManagerFactory.class.getName());

properties.put(“drools.processSignalManagerFactory”,
DefaultSignalManagerFactory.class.getName());

KnowledgeSessionConfiguration config = KnowledgeBaseFactory
.newKnowledgeSessionConfiguration(properties);

In this case we tell Drools to use two jBPM5 related class factory. That’s all. You can extend the example further by creating new BPMN2 processes and execute them in the test (if you haven’t yet figured out , you can execute the test by calling ‘mvn test’).

Summary

Now you should be able to develop jBPM5 based applications using this Maven POM and HelloWorld test class as a base. In the next few posts, we will model a process, deploy it and finally execute it.

JBPM5 professional services

Plugtree LLC offers enterprise services for jBPM5 and Drools 5: custom training suited to your company’s needs, a variety of consulting topics from architecture reviews, best practices and performance tuning, and an all encompassing production support with SLAs according to your needs. We’ve helped dozens of clients to adopt the Drools and jBPM technologies across a variety of industries and you can be one of them too. Contact us: info@plugtree.com

Share

Related posts:

  1. Are you ready for Drools 5.2 + jbpm5?
  2. Jetty + DataSource + JTA
  3. Building JBPM5 from source
  4. Event Driven Business Process Management in jBPM5
  5. Drools Flow and BPMN2 – #1 Simple Validation Flow