Modeling with Zeebe BPMN Model API

Hi guys.
I use Zeebe BPMN Model API(version 0.21.0) to create a Workflow. When i deploy it to Zeebe, i got an ERROR – “Must have exactly one zeebe:taskDefinition extension element”
How can I add “zeebe:taskDefinition extention element” when i model with Zeebe BPMN Model API?

Blockquote
public static void testCreateInvoiceProcess() throws Exception{
BpmnModelInstance modelInstance = (BpmnModelInstance) Bpmn
.createExecutableProcess(“invoice”)
.startEvent()
.name(“Invoice received”)
.serviceTask()
.name(“assign Approver”)
.endEvent()
.done();
Bpmn.validateModel(modelInstance);
File file = File.createTempFile(“InvoiceProcess”, “.bpmn”, new File("/Users/lkestk/tmp"));
Bpmn.writeModelToFile(file,modelInstance);
}

1 Like

Hi @lkestk,

you need to set the job type on the service task.

 Bpmn
.createExecutableProcess(“invoice”)
.startEvent()
.name(“Invoice received”)
.serviceTask(serviceTask -> serviceTask.name(“assign Approver”).zeebeTaskType("foo"))
.endEvent()
.done();

The model API is heavily used in our engine unit tests. For example: https://github.com/zeebe-io/zeebe/blob/develop/engine/src/test/java/io/zeebe/engine/processor/workflow/activity/ServiceTaskTest.java

Does this help you?

Best regards,
Philipp

2 Likes

@philipp.ossler Thanks for you reply, this’s very helpful for me!