JBoss.org Community Documentation

- Prev
- Next

## Chapter 7. Core Engine: BPMN 2.0

## 7.1. Business Process Model and Notation (BPMN) 2.0 specification

    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:

- Events: They are used to model the occurrence of a particular event. This could be a start event (that is used to indicate the start of the process), end events (that define the end of the process, or of that subflow) and intermediate events (that indicate events that might occur during the execution of the process).
- Activities: These define the different actions that need to be performed during the execution of the process. Different types of tasks exist, depending on the type of activity you are trying to model (e.g. human task, service task, etc.) and activities could also be nested (using different types of sub-processes).
- Gateways: Can be used to define multiple paths in the process. Depending on the type of gateway, these might indicate parallel execution, choice, etc.

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:

- Flow objects
  - Events
    - Start Event (None, Conditional, Signal, Message, Timer)
    - End Event (None, Terminate, Error, Escalation, Signal, Message, Compensation)
    - Intermediate Catch Event (Signal, Timer, Conditional, Message)
    - Intermediate Throw Event (None, Signal, Escalation, Message, Compensation)
    - Non-interrupting Boundary Event (Escalation, Timer)
    - Interrupting Boundary Event (Escalation, Error, Timer, Compensation)
  - Activities
    - Script Task
    - Task
    - Service Task
    - User Task
    - Business Rule Task
    - Manual Task
    - Send Task
    - Receive Task
    - Reusable Sub-Process (Call Activity)
    - Embedded Sub-Process
    - Ad-Hoc Sub-Process
    - Data-Object
  - Gateways
    - Diverging
      - Exclusive
      - Inclusive
      - Parallel
      - Event-Based
    - Converging
      - Exclusive
      - Parallel
  - Lanes
- Data
  - Java type language
  - Process properties
  - Embedded Sub-Process properties
  - Activity properties
- Connecting objects
  - Sequence flow

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

- Create a new Flow file using the Drools Eclipse plugin wizard and in the last page of the wizard, make sure you select Drools 5.1 code compatibility. This will create a new process using the BPMN 2.0 XML format. Note however that this is not exactly a BPMN 2.0 editor, as it still uses different attributes names etc. It does however save the process using valid BPMN 2.0 syntax. Also note that the editor does not support all node types and attributes that are already supported in the execution engine.

- The Designer is an open-source web-based editor that supports the BPMN 2.0 format. We have embedded it into Guvnor for BPMN 2.0 process visualization and editing. You could use the Designer (either standalone or integrated) to create / edit BPMN 2.0 processes and then export them to BPMN 2.0 format or save them into Guvnor and import them so they can be executed.

- A new BPMN2 Eclipse plugin is being created to support the full BPMN2 specification. It is currently still under development and only supports a limited number of constructs and attributes, but can already be used to create simple BPMN2 processes. To create a new BPMN2 file for this editor, use the wizard (under Examples) to create a new BPMN2 file, which will generate a .bpmn2 file and a .prd file containing the graphical information. Double-click the .prd file to edit the file using the graphical editor. For more detail, check out the chapter on the new BPMN2 Eclipse plugin.

- You can always manually create your BPMN 2.0 process files by writing the XML directly. You can validate the syntax of your processes against the BPMN 2.0 XSD, or use the validator in the Eclipse plugin to check both syntax and completeness of your model.

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.

## 7.2. Examples

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.

## 7.3. Supported elements / attributes

Table 7.1. Keywords

Element | Supported attributes | Supported elements | Extension attributes | Extension 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 | operation |  |
operation | name id | inMessageRef |  |
laneSet |  | lane |  |
lane | name id | flowNodeRef |  |
import* |  | name |  |
global* |  | identifier type |  |
Events |  |  |  |
startEvent | name id | dataOutput dataOutputAssociation outputSet eventDefinition | x y width height |
endEvent | name id | dataInput dataInputAssociation inputSet eventDefinition | x y width height |
intermediateCatchEvent | name id | dataOutput dataOutputAssociation outputSet eventDefinition | x y width height |
intermediateThrowEvent | name id | dataInput dataInputAssociation inputSet eventDefinition | x y width height |
boundaryEvent | cancelActivity attachedToRef name id | eventDefinition | x y width height |
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 |  |
Activities |  |  |  |
task | name id | ioSpecification dataInputAssociation dataOutputAssociation | taskName x y width height |
scriptTask | scriptFormat name id | script | x y width height |
script |  | text[mixed content] |  |
userTask | name id | ioSpecification dataInputAssociation dataOutputAssociation resourceRole | x y width height | onEntry-script onExit-script
potentialOwner |  | resourceAssignmentExpression |  |
resourceAssignmentExpression |  | expression |  |
businessRuleTask | name id |  | x y width height ruleFlowGroup | onEntry-script onExit-script
manualTask | name id |  | x y width height | onEntry-script onExit-script
sendTask | messageRef name id | ioSpecification dataInputAssociation | x y width height | onEntry-script onExit-script
receiveTask | messageRef name id | ioSpecification dataOutputAssociation | x y width height | onEntry-script onExit-script
serviceTask | operationRef name id | ioSpecification dataInputAssociation dataOutputAssociation | x y width height | onEntry-script onExit-script
subProcess | name id | flowElement property loopCharacteristics | x y width height |
adHocSubProcess | cancelRemainingInstances name id | completionCondition flowElement property | x y width height |
callActivity | calledElement name id | ioSpecification dataInputAssociation dataOutputAssociation | x y width height waitForCompletion independent | onEntry-script onExit-script
multiInstanceLoopCharacteristics |  | loopDataInputRef inputDataItem loopDataOutputRef outputDataItem |  |
onEntry-script* | scriptFormat |  | script |
onExit-script* | scriptFormat |  | script |
Gateways |  |  |  |
parallelGateway | gatewayDirection name id |  | x y width height |
eventBasedGateway | gatewayDirection name id |  | x y width height |
exclusiveGateway | default gatewayDirection name id |  | x y width height |
inclusiveGateway | default gatewayDirection name id |  | x y width height |
Data |  |  |  |
property | itemSubjectRef id |  |  |
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 |  |  |

- PrevChapter 6. Core Engine: Basics
- Top of page
- Front page
- NextChapter 8. Core Engine: Persistence and transacti...