Deploy a Workflow
Related Resources
Prerequisites
- Running Zeebe broker with endpoint
localhost:26500
(default)
WorkflowDeployer.java
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Zeebe Community License 1.0. You may not use this file
* except in compliance with the Zeebe Community License 1.0.
*/
package io.zeebe.example.workflow;
import io.zeebe.client.ZeebeClient;
import io.zeebe.client.ZeebeClientBuilder;
import io.zeebe.client.api.response.DeploymentEvent;
public final class WorkflowDeployer {
public static void main(final String[] args) {
final String broker = "localhost:26500";
final ZeebeClientBuilder clientBuilder =
ZeebeClient.newClientBuilder().gatewayAddress(broker).usePlaintext();
try (final ZeebeClient client = clientBuilder.build()) {
final DeploymentEvent deploymentEvent =
client.newDeployCommand().addResourceFromClasspath("demoProcess.bpmn").send().join();
System.out.println("Deployment created with key: " + deploymentEvent.getKey());
}
}
}
demoProcess.bpmn
Download the XML and save it in the Java classpath before running the example. Open the file with Zeebe Modeler for a graphical representation.
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.5.0-nightly">
<bpmn:process id="demoProcess" isExecutable="true">
<bpmn:startEvent id="start" name="start">
<bpmn:outgoing>SequenceFlow_1sz6737</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1sz6737" sourceRef="start" targetRef="taskA" />
<bpmn:sequenceFlow id="SequenceFlow_06ytcxw" sourceRef="taskA" targetRef="taskB" />
<bpmn:sequenceFlow id="SequenceFlow_1oh45y7" sourceRef="taskB" targetRef="taskC" />
<bpmn:endEvent id="end" name="end">
<bpmn:incoming>SequenceFlow_148rk2p</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_148rk2p" sourceRef="taskC" targetRef="end" />
<bpmn:serviceTask id="taskA" name="task A">
<bpmn:extensionElements>
<zeebe:taskDefinition type="foo" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1sz6737</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_06ytcxw</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="taskB" name="task B">
<bpmn:extensionElements>
<zeebe:taskDefinition type="bar" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_06ytcxw</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1oh45y7</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="taskC" name="task C">
<bpmn:extensionElements>
<zeebe:taskDefinition type="foo" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1oh45y7</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_148rk2p</bpmn:outgoing>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="demoProcess">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="start">
<dc:Bounds x="173" y="102" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="180" y="138" width="22" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1sz6737_di" bpmnElement="SequenceFlow_1sz6737">
<di:waypoint xsi:type="dc:Point" x="209" y="120" />
<di:waypoint xsi:type="dc:Point" x="310" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="260" y="105" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_06ytcxw_di" bpmnElement="SequenceFlow_06ytcxw">
<di:waypoint xsi:type="dc:Point" x="410" y="120" />
<di:waypoint xsi:type="dc:Point" x="502" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="456" y="105" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1oh45y7_di" bpmnElement="SequenceFlow_1oh45y7">
<di:waypoint xsi:type="dc:Point" x="602" y="120" />
<di:waypoint xsi:type="dc:Point" x="694" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="648" y="105" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="EndEvent_0gbv3sc_di" bpmnElement="end">
<dc:Bounds x="867" y="102" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="876" y="138" width="18" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_148rk2p_di" bpmnElement="SequenceFlow_148rk2p">
<di:waypoint xsi:type="dc:Point" x="794" y="120" />
<di:waypoint xsi:type="dc:Point" x="867" y="120" />
<bpmndi:BPMNLabel>
<dc:Bounds x="831" y="105" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_09m0goq_di" bpmnElement="taskA">
<dc:Bounds x="310" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_0sryj72_di" bpmnElement="taskB">
<dc:Bounds x="502" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_1xu4l3g_di" bpmnElement="taskC">
<dc:Bounds x="694" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>