JBoss.orgCommunity Documentation

Chapter 7. Core Engine: BPMN 2.0

7.1. Business Process Model and Notation (BPMN) 2.0 specification
7.2. Examples
7.3. Supported elements / attributes
The primary goal of BPMN is to provide a notation that is readily understandable by all business users,
from the business analysts that create the initial drafts of the processes, to the technical developers
responsible for implementing the technology that will perform those processes, and finally, to the
business people who will manage and monitor those processes."

The Business Process Model and Notation (BPMN) 2.0 specification is an OMG specification that not only defines a standard on how to graphically represent a business process (like BPMN 1.x), but now also includes execution semantics for the elements defined, and an XML format on how to store (and share) process definitions.

jBPM5 allows you to execute processes defined using the BPMN 2.0 XML format. That means that you can use all the different jBPM5 tooling to model, execute, manage and monitor your business processes using the BPMN 2.0 format for specifying your executable business processes. Actually, the full BPMN 2.0 specification also includes details on how to represent things like choreographies and collaboration. The jBPM project however focuses on that part of the specification that can be used to specify executable processes.

Executable processes in BPMN consist of a different types of nodes being connected to each other using sequence flows. The BPMN 2.0 specification defines three main types of nodes:

jBPM5 does not implement all elements and attributes as defined in the BPMN 2.0 specification. We do however support a significant subset, including the most common node types that can be used inside executable processes. This includes (almost) all elements and attributes as defined in the "Common Executable" subclass of the BPMN 2.0 specification, extended with some additional elements and attributes we believe are valuable in that context as well. The full set of elements and attributes that are supported can be found below, but it includes elements like:

For example, consider the following "Hello World" BPMN 2.0 process, which does nothing more that writing out a "Hello World" statement when the process is started.

An executable version of this process expressed using BPMN 2.0 XML would look something like this:


<?xml version="1.0" encoding="UTF-8"?> 
<definitions id="Definition"
             targetNamespace="http://www.example.org/MinimalExample"
             typeLanguage="http://www.java.com/javaTypes"
             expressionLanguage="http://www.mvel.org/2.0"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
             xs:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
             xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
             xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
             xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
             xmlns:tns="http://www.jboss.org/drools">

  <process processType="Private" isExecutable="true" id="com.sample.HelloWorld" name="Hello World" >

    <!-- nodes -->
    <startEvent id="_1" name="StartProcess" />
    <scriptTask id="_2" name="Hello" >
      <script>System.out.println("Hello World");</script>
    </scriptTask>
    <endEvent id="_3" name="EndProcess" >
        <terminateEventDefinition/>
    </endEvent>

    <!-- connections -->
    <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
    <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" />

  </process>

  <bpmndi:BPMNDiagram>
    <bpmndi:BPMNPlane bpmnElement="Minimal" >
      <bpmndi:BPMNShape bpmnElement="_1" >
        <dc:Bounds x="15" y="91" width="48" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_2" >
        <dc:Bounds x="95" y="88" width="83" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_3" >
        <dc:Bounds x="258" y="86" width="48" height="48" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="_1-_2" >
        <di:waypoint x="39" y="115" />
        <di:waypoint x="75" y="46" />
        <di:waypoint x="136" y="112" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_2-_3" >
        <di:waypoint x="136" y="112" />
        <di:waypoint x="240" y="240" />
        <di:waypoint x="282" y="110" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>

</definitions>

To create your own process using BPMN 2.0 format, you can

The following code fragment shows you how to load a BPMN2 process into your knowledge base ...

private static KnowledgeBase createKnowledgeBase() throws Exception {

  KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
  kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn2"), ResourceType.BPMN2);
  return kbuilder.newKnowledgeBase();
}

... and how to execute this process ...

KnowledgeBase kbase = createKnowledgeBase();

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.startProcess("com.sample.HelloWorld");

For more detail, check out the chapter on the API and the basics.

The BPMN 2.0 specification defines the attributes and semantics of each of the node types (and other elements).

The jbpm-bpmn2 module contains a lot of junit tests for each of the different node types. These test processes can also serve as simple examples: they don't really represent an entire real life business processes but can definitely be used to show how specific features can be used. For example, the following figures shows the flow chart of a few of those examples. The entire list can be found in the src/main/resources folder for the jbpm-bpmn2 module like here.

Table 7.1. Keywords

ElementSupported attributesSupported elementsExtension attributesExtension elements
definitions rootElement BPMNDiagram  
processprocessType isExecutable name idproperty laneSet flowElementpackageName adHoc versionimport global
sequenceFlowsourceRef targetRef isImmediate name idconditionExpressionpriority 
interfacename idoperation  
operationname idinMessageRef  
laneSet lane  
lanename idflowNodeRef  
import* name  
global* identifier type  
     
Events    
startEventname iddataOutput dataOutputAssociation outputSet eventDefinitionx y width height 
endEventname iddataInput dataInputAssociation inputSet eventDefinitionx y width height 
intermediateCatchEventname iddataOutput dataOutputAssociation outputSet eventDefinitionx y width height 
intermediateThrowEventname iddataInput dataInputAssociation inputSet eventDefinitionx y width height 
boundaryEventcancelActivity attachedToRef name ideventDefinitionx y width height 
terminateEventDefinition    
compensateEventDefinitionactivityRefdocumentation extensionElements  
conditionalEventDefinition condition  
errorEventDefinitionerrorRef   
errorerrorCode id   
escalationEventDefinitionescalationRef   
escalationescalationCode id   
messageEventDefinitionmessageRef   
messageitemRef id   
signalEventDefinitionsignalRef   
timerEventDefinition timeCycle timeDuration  
     
Activities    
taskname idioSpecification dataInputAssociation dataOutputAssociationtaskName x y width height 
scriptTaskscriptFormat name idscriptx y width height 
script text[mixed content]  
userTaskname idioSpecification dataInputAssociation dataOutputAssociation resourceRolex y width heightonEntry-script onExit-script
potentialOwner resourceAssignmentExpression  
resourceAssignmentExpression expression  
businessRuleTaskname id x y width height ruleFlowGrouponEntry-script onExit-script
manualTaskname id x y width heightonEntry-script onExit-script
sendTaskmessageRef name idioSpecification dataInputAssociationx y width heightonEntry-script onExit-script
receiveTaskmessageRef name idioSpecification dataOutputAssociationx y width heightonEntry-script onExit-script
serviceTaskoperationRef name idioSpecification dataInputAssociation dataOutputAssociationx y width heightonEntry-script onExit-script
subProcessname idflowElement property loopCharacteristicsx y width height 
adHocSubProcesscancelRemainingInstances name idcompletionCondition flowElement propertyx y width height 
callActivitycalledElement name idioSpecification dataInputAssociation dataOutputAssociationx y width height waitForCompletion independentonEntry-script onExit-script
multiInstanceLoopCharacteristics loopDataInputRef inputDataItem loopDataOutputRef outputDataItem  
onEntry-script*scriptFormat script 
onExit-script*scriptFormat script 
     
Gateways    
parallelGatewaygatewayDirection name id x y width height 
eventBasedGatewaygatewayDirection name id x y width height 
exclusiveGatewaydefault gatewayDirection name id x y width height 
inclusiveGatewaydefault gatewayDirection name id x y width height 
     
Data    
propertyitemSubjectRef id   
dataObjectitemSubjectRef id   
itemDefinitionstructureRef id   
ioSpecification dataInput dataOutput inputSet outputSet  
dataInputname id   
dataInputAssociation sourceRef targetRef assignment  
dataOutputname id   
dataOutputAssociation sourceRef targetRef assignment  
inputSet dataInputRefs  
outputSet dataOutputRefs  
assignment from to  
formalExpressionlanguagetext[mixed content]  
     
BPMNDI    
BPMNDiagram BPMNPlane  
BPMNPlanebpmnElementBPMNEdge BPMNShape  
BPMNShapebpmnElementBounds  
BPMNEdgebpmnElementwaypoint  
Boundsx y width height   
waypointx y