JBPM tutorial

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive

JBoss jBPM 3 is a flexible, extensible framework for process languages which uses graph oriented programming as a foundation. As the word says it, a graph based language represent some kind of execution which can be shown as a graph (Imagine a simple flow chart which explains the track of a business decision for example).

Business process management can be defined as a procedure in an organization: some of this procedures can be automated, some need human work.

Why we need a BPM in Java ?

the basic of an interaction with other systems is the exchange of information/messages


Response r = waitForResponseFromB();

What is the limitation with this ? the first limitation is that by itself this little code is not persistable, yes of course you can wrap it with some Object/Relational tool...but what about waiting states ? even if you implement it as a Thread you cannot persist a Java Thread.

The second one is that you might need a graphical representation of this......for example your Boss wants to take a look at your process...or even more, what about if business changes ? without a native graphical implementation of the process you have to do double work: re-engineering the Code and the Graph with your favourite tool.

So now let's get our hand dirty ! The first thing to do is to download a fresh copy of JBPM fron jBoss site. For this article we'll use jbpm-jpdl-suite-3.2.3.zip downloadable from www.jboss.org site.

This archive includes embedded application server (JBoss of course) and the graphical designer. Before entering in the details let's make clear one thing: usually BPM engines have a tight coupling with the graphical environment : meaning you have to use the graphical editor to draw or change your process. JBPM is basically a process management Api built on Hibernate (which maps the basic workflow tables) and it can live well without any graphical editor. It does exists a plugin built with Eclipse technology which lets you reverse-engineer your graphical process into an XML file, yet you can still design your process with a simple notepad and a Java compiler.

So keep separated the concept of the Graphical Process Designer (GPD), which will be used by analyst/ top managers to describe the process and the process it self which is only xml and pure Java. Nice separation of tasks between analysts and developers isn't it ? 

So we talked about XML: what is the process language of jBPM? there are more then one but just for beginning we'll concentrate on the most common: that is jPDL. JPDL is an XML structured language which has a specific process grammar to describe process definitions, nodes and transitions.

Meanwhile you read this article I guess you have finished downloading jbpm-jpdl-suite-3.2.3.zip. So unzip it and launch the designer.bat (or designer.sh for Unix/Linux users) under the "designer" folder.

Once Eclipse is started, launch the "New..." Menu and select new Process project

  JBPM tutorial

Then choose a convenient name for your Project and wait until you'll see your Project in the Package explored. Resist one more minute before looking at your process: open the JBPM library tag in the Package explorer: you'll see the libraries needed to run your process from a standalone application. Quite a lot, isn't it ? but only two of them are the core jBPM libraries, all the others are just dependancies.

  • jbpm-3.x.x.jar
  • jbpm-identity-3.x.x.jar

So if you plan to run your application on a JBoss application server these 2 are the only libraries you'll need to add to your war/ear file. We'll start with a simple process which describes an order management system.



The process is quite straightforward : once the process is started we meet a Task Node: in short a task node represents an activity that is performed by humans. This task will be in charge of user "buyer".

Once the order is performed we have a Decision Node where the process can lead to different Nodes based on the data at its disposal. In our case we check if the goods ordered are available. If they're not available the process is switched to a State Node named "GetFromStock". A State Node simply tells the process instance to wait and, in contrast to a task node, it doesn't create an activity in anybody's task list.

At last our goods needs to be shipped and this will be another task in charge to our Deliver Office. Once also this task is completed our process will come to a end.


Related articles available on mastertheboss.com

How do I fire an action every time a JBPM Node enters?

JBoss recipe of the day

JBoss Jbpm superstates

What is a superstate ? a Superstate is a group of nodes. Supersta

Jbpm Mail delivery

Almost every workflow needs a notification of the process activit

How do you embed Java code in your JPDL ?

  You can use a BeanShell expression to add a Java script in you

JBPM best practices

There's no perfect rule to model your workflow, it depends on the

How to delete/persist your JBPM process after restart ?

JBoss recipe of the day

JBoss CheatSheet for Admins