-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathzeebe_client.py
More file actions
27 lines (19 loc) · 1.11 KB
/
zeebe_client.py
File metadata and controls
27 lines (19 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import grpc
import gateway_pb2
import gateway_pb2_grpc
def run():
with grpc.insecure_channel('localhost:26500') as channel:
stub = gateway_pb2_grpc.GatewayStub(channel)
topologyResponse = stub.Topology(gateway_pb2.TopologyRequest())
print(topologyResponse)
listResponse = stub.ListWorkflows(gateway_pb2.ListWorkflowsRequest())
print(listResponse)
createResponse = stub.CreateWorkflowInstance(gateway_pb2.CreateWorkflowInstanceRequest(bpmnProcessId = 'simple-process', version = -1, payload = '{"orderId" : "ab1234"}'))
print(createResponse)
for jobResponse in stub.ActivateJobs(gateway_pb2.ActivateJobsRequest(type = 'payment-service', worker = 'zeebe-client-test', timeout = 1000, amount = 32)):
for job in jobResponse.jobs:
print(job)
stub.CompleteJob(gateway_pb2.CompleteJobRequest(jobKey = job.key))
stub.PublishMessage(gateway_pb2.PublishMessageRequest(name ='payment-confirmed', correlationKey = "ab1234", timeToLive = 100000, payload = '{"total-charged" : 25.95}' ))
if __name__ == '__main__':
run()