domingo, 13 de novembro de 2016

Importing Work Item Handlers in jBPM using a custom service repository

We previously talked about creating a custom Work Item Handler and how to import it in the jBPM designer. The process is not simple, it requires some manual steps and it is error prone - even some users had problems as you can see in the post comment's section.

jBPM 6.5 comes with a great new feature that makes easier to import services. In this post I will show you how to use this new feature.

A very simple Work Item Handler

Remember our hello world work item handler? Let's clone it and install it on your local maven using mvn clean install
Now create a directory on your installacation called repository. It should have a file with content "HelloWorld" and a child directory called HelloWorld. Inside this directory we should have a file named HelloWorld.wid with the following content:

[  [    "name" : "HelloWorld",    "description" : "Prints hello World in the console",    "displayName" : "Hello World!",    "defaultHandler" : "mvel: new org.jugvale.jbpm.workitemhandler.HelloWorkItemHandler()",    "mavenDependencies" : [          "org.jugvale.jbpm.workitemhandler:hello-workitemhandler:1.0"     ]  ]]

This file describes how jBPM can install your Work Item Handler, you can write it using JSON or MVEL(as above. A quick explanation about the fields can be found in JBPM documentation.
The final repository structure can be found below:

The next step is install this on jBPM and this can be done by using the sytem parameters org.jbpm.service.repository and org.jbpm.service.servicetasknames during jBPM startup:

./bin/ -c standalone-full.xml -Dorg.jbpm.service.repository=file:///opt/repository -Dorg.jbpm.service.servicetasknames=HelloWorld

In this case you can choose what services you want to register using the system property org.jbpm.service.servicetasknames,  but you can't use "*". The property org.jbpm.service.repository accepts a URL and it can be a remote repository.

The other way is by opening the process designer and clicking on the yellow icon. Then you click on the "tool" icon and reopen the process designer and you should be able to see your service task available for use.

Notice also that it registers the Work Item Handler in the deployment descriptor as well and due JBPM-5411, be careful if you don't use a resolver for your WIH.


I created this post because the other one is outdated. We don't even use kmodule.xml anymore! However, the official documentation for this feature is real good!

Nenhum comentário:

Postar um comentário