Creating Models Programmatically (C8)

In platform 7, BPMN models can be created programmatically.
I wonder if such a possibility is available in platform 8.

Hey @hassang

yes we have a port of it for Zeebe as well. It is part of the Zeebe repo see here zeebe/bpmn-model at main · camunda/zeebe · GitHub

Greets
Chris

1 Like

Hi @Zelldon,

Are there any related examples or documentation?
Thanks in advance…

Thanks @Zelldon

I managed to do a small test.

  • Imported the required maven dependency as below
<dependency>
	<groupId>io.camunda</groupId>
	<artifactId>zeebe-bpmn-model</artifactId>
	<version>8.0.2</version>
</dependency>
  • Code is identical to C7 code
BpmnModelInstance modelInstance;
File file;

modelInstance = 
		Bpmn.createProcess()
			.name("Example process")
			.id("example-process")
			.executable()
		.startEvent()
		.userTask()
			.name("Task 1")
			.id("ut-task1")
			.zeebeAssignee("test-user")
		.endEvent()
		.done();

file = new File("C:\\model-api-test\\example-c8-process.bpmn");

try {
	
	file.createNewFile();
	
} catch (IOException e) {

	System.out.println("Error: " + e.getMessage());
}

Bpmn.writeModelToFile(file, modelInstance);
4 Likes

Hey @hassang

sorry for the late reply. I was not able to send a good example before since I was only available via mobile. Thanks for sharing your solution :slight_smile:

You can also take a look at the engine tests, e.g. zeebe/CreateProcessInstanceTest.java at main · camunda/zeebe · GitHub where we use the model API everywhere.

Greets
Chris

1 Like