JBoss.orgCommunity Documentation

Chapter 6. Core Engine: BPMN 2.0

6.1. Business Process Model and Notation (BPMN) 2.0 specification
6.2. Supported elements / attributes
6.3. Examples

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.

jBPM6 allows you to execute processes defined using the BPMN 2.0 XML format. That means that you can use all the different jBPM6 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:

jBPM6 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 {
    KieHelper kieHelper = new KieHelper();
    KieBase kieBase = kieHelper
    .addResource(ResourceFactory.newClassPathResource("sample.bpmn2"))
    .build();
    return kieBase;
}

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

KieBase kbase = createKnowledgeBase();

KieSession ksession = kbase.newKieSession();
ksession.startProcess("com.sample.HelloWorld");

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

Table 6.1. Keywords

ElementSupported attributesSupported elementsExtension attributesExtension elements
definitions 

  • rootElement
  • BPMNDiagram

  
process

  • processType
  • isExecutable
  • name
  • id

  • property
  • laneSet
  • flowElement

  • packageName
  • adHoc
  • version

  • import
  • global

sequenceFlow

  • sourceRef
  • targetRef
  • isImmediate
  • name
  • id

  • conditionExpression

  • priority

 
interface

  • name
  • id
  • implementationRef

  • operation

  
operation

  • name
  • id
  • implementationRef

  • inMessageRef

  
laneSet 

  • lane

  
lane

  • name
  • id

  • flowNodeRef

  
import* 

  • name

  
global* 

  • identifier
  • type

  
     
Events    
startEvent

  • name
  • id
  • isInterrupting

  • dataOutput
  • dataOutputAssociation
  • outputSet
  • eventDefinition

  
endEvent

  • name
  • id

  • dataInput
  • dataInputAssociation
  • inputSet
  • eventDefinition

  
intermediateCatchEvent

  • name
  • id

  • dataOutput
  • dataOutputAssociation
  • outputSet
  • eventDefinition

  
intermediateThrowEvent

  • name
  • id

  • dataInput
  • dataInputAssociation
  • inputSet
  • eventDefinition

  
boundaryEvent

  • cancelActivity
  • attachedToRef
  • name
  • id

  • eventDefinition

  
terminateEventDefinition    
compensateEventDefinition

  • activityRef

  • documentation
  • extensionElements

  
conditionalEventDefinition 

  • condition

  
errorEventDefinition

  • errorRef

   
error

  • errorCode
  • id

   
escalationEventDefinition

  • escalationRef

   
escalation

  • escalationCode
  • id

   
messageEventDefinition

  • messageRef

   
message

  • itemRef
  • id

   
signalEventDefinition

  • signalRef

   
timerEventDefinition 

  • timeCycle
  • timeDuration
  • timerDate

  
     
Activities    
task

  • name
  • id

  • ioSpecification
  • dataInputAssociation
  • dataOutputAssociation

  • taskName

 
scriptTask

  • scriptFormat
  • name
  • id

  • script

  
script 

  • text[mixed content]

  
userTask

  • name
  • id

  • ioSpecification
  • dataInputAssociation
  • dataOutputAssociation
  • resourceRole
  • loopCharacteristics

 

  • onEntry-script
  • onExit-script

potentialOwner 

  • resourceAssignmentExpression

  
resourceAssignmentExpression 

  • expression

  
businessRuleTask

  • name
  • id

  • ioSpecification
  • dataInputAssociation
  • dataOutputAssociation

  • ruleFlowGroup

  • onEntry-script
  • onExit-script

manualTask

  • name
  • id

  

  • onEntry-script
  • onExit-script

sendTask

  • messageRef
  • name
  • id

  • ioSpecification
  • dataInputAssociation
  • loopCharacteristics

 

  • onEntry-script
  • onExit-script

receiveTask

  • messageRef
  • name
  • id

  • ioSpecification
  • dataOutputAssociation
  • loopCharacteristics

 

  • onEntry-script
  • onExit-script

serviceTask

  • operationRef
  • name
  • id
  • implementation

  • ioSpecification
  • dataInputAssociation
  • dataOutputAssociation
  • loopCharacteristics

 

  • onEntry-script
  • onExit-script

subProcess

  • name
  • id
  • triggeredByEvent

  • flowElement
  • property
  • loopCharacteristics

  
adHocSubProcess

  • cancelRemainingInstances
  • name
  • id

  • completionCondition
  • flowElement
  • property

  
callActivity

  • calledElement
  • name
  • id

  • ioSpecification
  • dataInputAssociation
  • dataOutputAssociation

  • waitForCompletion
  • independent

  • onEntry-script
  • onExit-script

multiInstanceLoopCharacteristics 

  • loopDataInputRef
  • inputDataItem
  • loopDataOutputRef
  • outputDataItem

  
onEntry-script*

  • scriptFormat

 

  • script

 
onExit-script*

  • scriptFormat

 

  • script

 
     
Gateways    
parallelGateway

  • gatewayDirection
  • name
  • id

   
eventBasedGateway

  • gatewayDirection
  • name
  • id

   
exclusiveGateway

  • default
  • gatewayDirection
  • name
  • id

   
inclusiveGateway

  • default
  • gatewayDirection
  • name
  • id

   
     
Data    
property

  • itemSubjectRef
  • id
  • name

   
dataObject

  • itemSubjectRef
  • id

   
itemDefinition

  • structureRef
  • id

   
ioSpecification 

  • dataInput
  • dataOutput
  • inputSet
  • outputSet

  
dataInput

  • name
  • id

   
dataInputAssociation 

  • sourceRef
  • targetRef
  • assignment

  
dataOutput

  • name
  • id

   
dataOutputAssociation 

  • sourceRef
  • targetRef
  • assignment

  
inputSet 

  • dataInputRefs

  
outputSet 

  • dataOutputRefs

  
assignment 

  • from
  • to

  
formalExpression

  • language

  • text[mixed content]

  
     
BPMNDI    
BPMNDiagram 

  • BPMNPlane

  
BPMNPlane

  • bpmnElement

  • BPMNEdge
  • BPMNShape

  
BPMNShape

  • bpmnElement

  • Bounds

  
BPMNEdge

  • bpmnElement

  • waypoint

  
Bounds

  • x
  • y
  • width
  • height

   
waypoint

  • x
  • y

   

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

TODO: provide more examples with more advanced constructs

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/test/resources folder for the jbpm-bpmn2 module like here.