Skip to main content
To create a new BPMN model from scratch you have to create an empty BPMN model instance with the following method:
The next step is to create a BPMN definitions element. Set the target namespace on it and add it to the newly created empty model instance.
Usually you want to add a process to your model. This follows the same 3 steps as the creation of the BPMN definitions element:
  1. Create a new instance of the BPMN element
  2. Set attributes and child elements of the element instance
  3. Add the newly created element instance to the corresponding parent element
To simplify this repeating procedure, you can use a helper method like this one.
After you created the elements of your process like start event, tasks, gateways and end event, you have to connect the elements with sequence flows. Again, this follows the same 3 steps of element creation and can be simplified by the following helper method.
Validate the model against the BPMN 2.0 specification and convert it to an XML string or save it to a file or stream.

Example 1: Create a Simple Process With One User Task

With the basic helper methods from above it is very easy and straightforward to create simple processes. First, create a process with a start event, user task and an end event. Single User Task Example The following code creates this process using the helper methods from above (without the DI elements).

Example 2: Create a Simple Process With Two Parallel Tasks

Even more complex processes can be created with a few lines of code with the standard BPMN model API. Parallel Task Example