Zeebe spring boot microservices example with timer

Hi Team,
i am trying to do sample example using Zeebe, spring boot microservices with timer (5 min, morning, evening and night build).Please suggest how to integrate microservices with zeebe.if there is any sample please share the url.

thanks
ramakrishna

@Ramakrishna hi there… your request is too generic, what are you trying to achieve exactly? what kind of integration? I think that @philipp.ossler already provided an alternative in another thread.

I am doing sample POC.My requirement is i have a timer(PT5M),it should call the rest service and process, result will be success or fail

Q1:How to setup a timer for multiple jobs(daily-job,weekly-job,monthly-job) in bpmn
Q2:How to consume Java REST service based on job type?

thanks.

@Ramakrishna so there are two things in there:

  1. find the expression to trigger the timer on your desired moments, once a day, once a week and once a month. Check the docs for this: https://docs.zeebe.io/bpmn-workflows/timer-events/timer-events.html#timers
  2. You need to create a worker for your Job type and then that worker will need to call your rest service and have the business logic to process the output of that call.

Thanks Salaboy for immediate reply. Could you please share github repository url if any example code is available related to “calling rest service using worker” .

thanks

@Ramakrishna there is nothing Zeebe specific with that… you can use any Java framework to call REST endpoint. From the Zeebe perspective you can do whatever you want inside the worker code.
For example here you can find a worker example: https://github.com/salaboy/zeebe-worker-spring-boot-example/blob/master/src/main/java/com/example/demo/DemoApplication.java#L25

But inside the @ZeebeWorker annotated method you can use for example Spring Boot WebClient or RestTemplate to call your service. For example: https://www.baeldung.com/rest-template

error
Hi Salaboy,
i gave ExclusiveGateway_0wqjsqh==0 also tried with ExclusiveGateway_0wqjsqh==1 at yes
but it is failing. continuously retry only executing.Please help me to execute success flow.

Thanks.

@Ramakrishna can you share your BPMN file? ExclusiveGateway_0wqjsqh==0 that doesn’t make much sense as an expression.

@salaboy Instead of bpmn file, i am sharing xml file.please paste in modeler,so that you will get bpmn file.

<?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:dc=“http://www.omg.org/spec/DD/20100524/DC” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns:zeebe=“http://camunda.org/schema/zeebe/1.0” xmlns:di=“http://www.omg.org/spec/DD/20100524/DI” id=“Definitions_0c317n4” targetNamespace=“http://bpmn.io/schema/bpmn” exporter=“Zeebe Modeler” exporterVersion=“0.8.0”>
<bpmn:process id=“mjprocess” name=“mjprocess” isExecutable=“true”>
<bpmn:sequenceFlow id=“SequenceFlow_07gotno” sourceRef=“start” targetRef=“jobexcuted” />
<bpmn:exclusiveGateway id=“ExclusiveGateway_0wqjsqh” name=“executed?” default=“SequenceFlow_0qg3zrm”>
bpmn:incomingSequenceFlow_0de9mw6</bpmn:incoming>
bpmn:outgoingSequenceFlow_00if7pf</bpmn:outgoing>
bpmn:outgoingSequenceFlow_0qg3zrm</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id=“SequenceFlow_0de9mw6” sourceRef=“jobexcuted” targetRef=“ExclusiveGateway_0wqjsqh” />
<bpmn:sequenceFlow id=“SequenceFlow_00if7pf” name=“yes” sourceRef=“ExclusiveGateway_0wqjsqh” targetRef=“alert-sent”>
<bpmn:conditionExpression xsi:type=“bpmn:tFormalExpression”>ExclusiveGateway_0wqjsqh==0</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:endEvent id=“end” name=“end”>
bpmn:incomingSequenceFlow_0yfstkb</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id=“SequenceFlow_0yfstkb” sourceRef=“alert-sent” targetRef=“end” />
<bpmn:sequenceFlow id=“SequenceFlow_0qg3zrm” name=“no” sourceRef=“ExclusiveGateway_0wqjsqh” targetRef=“retry-after-5min” />
<bpmn:intermediateCatchEvent id=“retry-after-5min” name=“retry-after-5min”>
bpmn:incomingSequenceFlow_0qg3zrm</bpmn:incoming>
bpmn:outgoingSequenceFlow_0rf31bb</bpmn:outgoing>
bpmn:timerEventDefinition
<bpmn:timeDuration xsi:type=“bpmn:tFormalExpression”>PT5M</bpmn:timeDuration>
</bpmn:timerEventDefinition>
</bpmn:intermediateCatchEvent>
<bpmn:sequenceFlow id=“SequenceFlow_0rf31bb” sourceRef=“retry-after-5min” targetRef=“jobexcuted” />
<bpmn:serviceTask id=“jobexcuted” name=“jobexcuted”>
bpmn:extensionElements
<zeebe:taskDefinition type=“jobexcuted” />
</bpmn:extensionElements>
bpmn:incomingSequenceFlow_07gotno</bpmn:incoming>
bpmn:incomingSequenceFlow_0rf31bb</bpmn:incoming>
bpmn:outgoingSequenceFlow_0de9mw6</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id=“alert-sent” name=“alert-sent”>
bpmn:extensionElements
<zeebe:taskDefinition type=“alert-sent” />
</bpmn:extensionElements>
bpmn:incomingSequenceFlow_00if7pf</bpmn:incoming>
bpmn:outgoingSequenceFlow_0yfstkb</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:startEvent id=“start” name=“start”>
bpmn:outgoingSequenceFlow_07gotno</bpmn:outgoing>
bpmn:timerEventDefinition
<bpmn:timeCycle xsi:type=“bpmn:tFormalExpression”>R/PT1M</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>
</bpmn:process>
<bpmndi:BPMNDiagram id=“BPMNDiagram_1”>
<bpmndi:BPMNPlane id=“BPMNPlane_1” bpmnElement=“mjprocess”>
<bpmndi:BPMNEdge id=“SequenceFlow_07gotno_di” bpmnElement=“SequenceFlow_07gotno”>
<di:waypoint x=“215” y=“117” />
<di:waypoint x=“270” y=“117” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id=“ExclusiveGateway_0wqjsqh_di” bpmnElement=“ExclusiveGateway_0wqjsqh” isMarkerVisible=“true”>
<dc:Bounds x=“425” y=“92” width=“50” height=“50” />
bpmndi:BPMNLabel
<dc:Bounds x=“425” y=“62” width=“51” height=“14” />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id=“SequenceFlow_0de9mw6_di” bpmnElement=“SequenceFlow_0de9mw6”>
<di:waypoint x=“370” y=“117” />
<di:waypoint x=“425” y=“117” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“SequenceFlow_00if7pf_di” bpmnElement=“SequenceFlow_00if7pf”>
<di:waypoint x=“475” y=“117” />
<di:waypoint x=“530” y=“117” />
bpmndi:BPMNLabel
<dc:Bounds x=“494” y=“99” width=“17” height=“14” />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id=“EndEvent_0tpsof6_di” bpmnElement=“end”>
<dc:Bounds x=“692” y=“99” width=“36” height=“36” />
bpmndi:BPMNLabel
<dc:Bounds x=“701” y=“142” width=“19” height=“14” />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id=“SequenceFlow_0yfstkb_di” bpmnElement=“SequenceFlow_0yfstkb”>
<di:waypoint x=“630” y=“117” />
<di:waypoint x=“692” y=“117” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id=“SequenceFlow_0qg3zrm_di” bpmnElement=“SequenceFlow_0qg3zrm”>
<di:waypoint x=“450” y=“142” />
<di:waypoint x=“450” y=“230” />
<di:waypoint x=“338” y=“230” />
bpmndi:BPMNLabel
<dc:Bounds x=“459” y=“183” width=“13” height=“14” />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id=“IntermediateCatchEvent_0lvmwv4_di” bpmnElement=“retry-after-5min”>
<dc:Bounds x=“302” y=“212” width=“36” height=“36” />
bpmndi:BPMNLabel
<dc:Bounds x=“285” y=“255” width=“76” height=“14” />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id=“SequenceFlow_0rf31bb_di” bpmnElement=“SequenceFlow_0rf31bb”>
<di:waypoint x=“320” y=“212” />
<di:waypoint x=“320” y=“157” />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id=“ServiceTask_1dqrjxj_di” bpmnElement=“jobexcuted”>
<dc:Bounds x=“270” y=“77” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id=“ServiceTask_1xrsn36_di” bpmnElement=“alert-sent”>
<dc:Bounds x=“530” y=“77” width=“100” height=“80” />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id=“StartEvent_1elrh1w_di” bpmnElement=“start”>
<dc:Bounds x=“179” y=“99” width=“36” height=“36” />
bpmndi:BPMNLabel
<dc:Bounds x=“186” y=“142” width=“23” height=“14” />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

thanks

Hi team,please help me. i am stuck up with gate way related.please check the above bpmn file and help me.

thanks
rk

@salaboy any update on bpmn expression

thanks
rk

Have you checked the documentation? -> https://docs.zeebe.io/bpmn-workflows/exclusive-gateways/exclusive-gateways.html
The expression needs to evaluate a workflow variable, you are not doing that. The xml shared is not correctly formatted so I cannot copy it and open it in the modeler here. Can you please host it in GitHub or dropbox and share the link to the file?

@salaboy tried like mentioned in the documentation but default flow (success == no )only executing instead of success == yes

thanks

@Ramakrishna that will probably never work. what is success? is that a workflow variable? You need to define that somewhere and then, if the variable is a boolean you will need to compare with == true or ==false.

Look at this BPMN file: https://github.com/salaboy/zeebe-k8s-getting-started/blob/master/emergency-process.bpmn#L36
There I have a gateway that is checking a String process variable called emergencyType. Before arriving to the gateway I need to make sure that the variable has a value so then in the expression I can compare it and decide. Are you doing all these steps?

@salaboy thanks for sharing reference link

1 Like

Hi @salaboy,
I went through this example but there is no bpmn file in resources folder.

Could you please help me if there is any other example with bpmn file.

thanks
rk

@Ramakrishna this one has the BPMN file inside the repo:

But it really doesn’t matter, you can deploy the workflow using Zeebe Ctl or using the Spring Zeebe Client as demonstrated in here:

Or even using the @Deployment annotation.

Hope that helps