Manage your business processes with JBoss jBPM

Get started using JBoss's business process management tool

Enterprises have searched diligently for a structured approach for designing business actions/transactions and executing them preferably using automated processes. Business process management (BPM) and workflow management offer a solution to this problem using concepts such as actions, tasks, and flows.

This article introduces BPM and discusses techniques and tools to empower enterprise systems with BPM and workflow management using JBoss jBPM.

The term business process management typically refers to a set of activities enterprises can employ to automate and optimize business processes in a manner adaptable to dynamically changing environments. These activities usually seek help from software engineering and tools; therefore, the term BPM is often used directly to refer to the engineering techniques and tools.

BPM is embodied in three distinct practices:

  1. Process design: The task of designing existing and new processes
  2. Process execution: The execution of an automated sequence of related events involving software processes and/or human activities
  3. Process monitoring: Observance and auditing of the state of individual processes so that the statistics and performance of these processes can be recorded, reported, and optimized

BPM seeks to allow software engineers to share the same concepts and frameworks as business analysts; consequentially, software vendors have attempted to create tools that will allow enterprises to capture, design, and optimize business processes through the employment of graphical modeling tools, domain-specific languages, and proprietary applications.

JBoss jBPM 3.0 delivers the capability of developing new automated business processes and workflows with industry-standard orchestration using Business Process Execution Language (BPEL), a flexible and pluggable API, a native process definition language, and a graphical modeling tool.

JBoss jBPM is an open source (LGPL license) framework of Java APIs, tools, and a definition language that can operate as a Web application or a standalone Java application. JBoss jBPM acts as an intermediary between business analysts and developers by giving them a common process definition language referred to as jPDL.

Overview of the JBoss jBPM architecture

JBoss jBPM defines process definitions within files written using the JBoss process definition language. jPDL is a graphic-oriented programming (GOP) language based on a model of nodes, transitions, and actions. In this model, nodes are commands executed as they are encountered during the flow of a process definition. Transitions direct the flow of execution of a process definition, and actions perform specific logic as a node or transition event occurs.

In jBPM, process definitions are packaged as process archives. A process archive is passed to the jPDL process engine for execution. The jPDL process engine traverses a process graph, executes defined actions, maintains process state, and logs all process events.

JBoss jBPM is encapsulated within the following components:

  • Process engine: This component executes defined process actions, maintains process state, and logs all process events via the following delegate components:
    • A request handler
    • A state manager
    • A log manager
    • A definition loader
    • An execution service
  • Process monitor: This module tracks, audits, and reports the state of processes as they execute
  • Process language: The process definition language (jPDL) is based on GOP
  • Interaction services: These services expose legacy applications as functions or data to be used in process executions

The relationships between these components are illustrated in Figure 1.

Figure 1. Component relationships of JBoss jBPM. Click on thumbnail to view full-sized image.

As shown in Figure 1, jBPM process definitions containing action handlers are loaded and executed by the jBPM process engine. When the process engine encounters a node in the process definition that has an action associated with it, all related action handlers are invoked. Action handlers are instances of Java code that interact with external systems when executed.

The following is an example of a simple action handler:

 

import org.jbpm.graph.def.*; import org.jbpm.graph.exe.*;

public class MyActionHandler implements ActionHandler { public void execute(ExecutionContext executionContext) { System.out.println("MyActionHandler has executed: " + executionContext); } }

The PDL file in a process archive is named process-definition.xml. This file contains the formal description of the processes. An example of a process-definition.xml file is illustrated in the following example:

 

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE process-definition PUBLIC "-//jbpm/jBPM Mapping DTD 2.0//EN" "http://jBPM.org/dtd/processdefinition-2.0.dtd"> <process-definition name="purchase process"> <!--...--> <!-- START-STATE --> <start-state name="request a purchase"> <transition to="evaluating"/> </start-state>

<!-- NODES --> <state name="evaluating"> <!--...--> <transition name="approve" to="purchase approved"/> <transition name="disapprove" to="done"/> </state> <fork name="purchase approved"> <transition to="decrement inventory" /> <transition to="increment revenue" /> </fork>

<state name="decrement inventory"> <!--...--> <transition to="join" /> </state>

<state name="increment revenue"> <!--...--> <transition to="join" /> </state> <join name="join"> <transition to="done" /> </join>

<!-- END-STATE --> <end-state name="done" /> </process-definition>

A process definition is based on a directed graph. The graph is composed of nodes, transitions, one start state, and one end state. The type of each node defines the runtime behavior for the node. While a process definition executes, the following entities come into play:

  • Process instance: A process instance is one execution of a process definition.
  • Token: A token is one path of execution. A token is the runtime concept that maintains a pointer to a node in the graph. When a process instance is created, a token is created for the main path of execution. This token is called the process instance's root token and is positioned in the process definition's start state.
  • Signal: A signal instructs a token to continue graph execution by transition out of a node.
  • Node: Nodes are responsible for the continuation of a graph execution. When a token enters a node, the node executes. A node that does not propagate execution is regarded as a state.
  • Action: Actions are instances of Java code executed when events occur in a process execution. The primary event types are "entering a node," "leaving a node," and "taking a transition."

Process definitions can be created easily with the jBPM graphical modeling designer. The designer is currently installed as an Eclipse plug-in. Figure 2 illustrates a sample screen from the graphical modeling designer.

Figure 2. The jBPM graphical modeling designer. Click on thumbnail to view full-sized image.

The graphical designer can be used to create process definitions, attach action handlers to events, edit definition source, create process archives, test process definitions, and so on.

Deploying JBoss jBPM

JBoss jBPM stores process definitions in a database. Therefore, deploying a process into JBoss jBPM involves parsing the process-definition.xml and storing it in the JBoss jBPM database. This can be done by:

  • Using the par Ant task supplied with JBoss jBPM to create a process archive.
  • Using the deploypar utility. This utility also creates a process archive and deploys the process archive to the jBPM database. The deploypar utility takes a jBPM.properties file as an attribute. This file specifies configuration options, including the database to which the process archive is to be deployed.
  • Programmatically parsing and storing the process-definition.xml into a datastore.

Running JBoss jBPM through some simple paces

JBoss jBPM acts as an orchestration engine that sits in the middle of enterprise applications, enabling integration and coordination between different applications.

For this article, I use the sample deployment shipped with jBPM to discuss how jBPM and jPDL are used to create and modify a simple Web-enabled order processing system.

Downloading JBoss jBPM

The JBoss jBPM starter kit contains everything needed to execute JBoss jBPM, with the exception of a JDK. The JBoss Application Server in the JBoss jBPM starter kit requires J2SE 1.4 or a more recent version.

After you have downloaded the starter kit, unzip it to a directory of your choosing. Once you have unzipped the starter kit, you will have a directory structure similar to the following:

  • Jbpm-starters-kit-3.1
    • jbpm: Contains the source code for the JBoss jBPM product
    • jbpm-bpel: Contains information about the BPEL extension for JBoss jBPM
    • jbpm-db: Contains sample configurations for connecting JBoss jBPM to other databases
    • jbpm-designer: Contains the Eclipse plug-in for the JBoss jBPM Visual Process Designer
    • jbpm-server: Contains the JBoss Application Server along with the JBoss jBPM engine and the sample process

Execute the JBoss jBPM engine

To start the JBoss application server with jBPM deployed, go to the jbpm-server directory and execute the startup script found there. A command window should pop up with the jBPM console window, similar to Figure 3.

Figure 3. The jBPM console window. Click on thumbnail to view full-sized image.

Now, bring up a browser window and go to http://localhost:8080/jbpm. You will be presented with the login page for the sample Web application for JBoss jBPM, shown in Figure 4.

Figure 4. The JBoss jBPM Web application login page. Click on thumbnail to view full-sized image.

Log in as cookie monster and select the Create New Web Sale Order link. This will create a new instance of the prebuilt "Web sale" process, illustrated in Figure 5.

Figure 5. Web sale process definition. Click on thumbnail to view full-sized image.

The actual definition file, processdefinition.xml, is located in websale.par and is illustrated in the following listing:

1 2 Page 1
Page 1 of 2