@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .timerWithDuration("PT0.01S") .endEvent() .done(); } },
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .timerWithDuration("PT0.01S") .endEvent() .done(); } },
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .message(b -> b.name(messageName()).zeebeCorrelationKey("$.id")) .endEvent() .done(); }
@Test public void shouldCompleteInstanceAfterInterruptingBoundaryEventTriggered() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToActivity("task") .boundaryEvent("timeout", b -> b.cancelActivity(true).timerWithDuration("PT0.1S")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .message(b -> b.name(messageName()).zeebeCorrelationKey("$.id")) .endEvent() .done(); }
@Test public void shouldCompleteInstanceAfterInterruptingBoundaryEventTriggered() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToActivity("task") .boundaryEvent("timeout", b -> b.cancelActivity(true).timerWithDuration("PT0.1S")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
@Test public void shouldUseScopeToExtractCorrelationKeys() { // given final String processId = "shouldHaveScopeKeyIfBoundaryEvent"; final BpmnModelInstance workflow = Bpmn.createExecutableProcess(processId) .startEvent() .serviceTask("task", c -> c.zeebeTaskType("type").zeebeInput("$.bar", "$.foo")) .boundaryEvent( "event", b -> b.message(m -> m.zeebeCorrelationKey("$.foo").name("message"))) .endEvent() .moveToActivity("task") .endEvent() .done(); testClient.deploy(workflow); // when testClient.createWorkflowInstance( processId, MsgPackUtil.asMsgPack(m -> m.put("foo", 1).put("bar", 2))); testClient.publishMessage("message", "1"); // then // if correlation key was extracted from the task, then foo in the task scope would be 2 and // no event occurred would be published assertThat(testClient.receiveElementInState("task", WorkflowInstanceIntent.EVENT_OCCURRED)) .isNotNull(); }
.cancelActivity(false) .message(m -> m.name("msg1").zeebeCorrelationKey("$.key")) .endEvent("msg1End") .moveToActivity("task") .endEvent("taskEnd")
.cancelActivity(false) .message(m -> m.name("msg1").zeebeCorrelationKey("$.key")) .endEvent("msg1End") .moveToActivity("task") .endEvent("taskEnd")
@Test public void shouldUseScopePayloadWhenApplyingOutputMappings() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", b -> b.zeebeTaskType("type").zeebeInput("$.oof", "$.baz")) .boundaryEvent("timer") .cancelActivity(true) .timerWithDuration("PT1S") .zeebeOutputBehavior(ZeebeOutputBehavior.merge) .endEvent("endTimer") .moveToActivity("task") .endEvent() .done(); testClient.deploy(workflow); testClient.createWorkflowInstance(PROCESS_ID, "{\"foo\": 1, \"oof\": 2}"); // when testClient.receiveTimerRecord("timer", TimerIntent.CREATED); brokerRule.getClock().addTime(Duration.ofMinutes(1)); awaitProcessCompleted(); // then final Record<WorkflowInstanceRecordValue> boundaryTriggered = testClient.receiveElementInState("timer", WorkflowInstanceIntent.EVENT_TRIGGERED); assertThat(boundaryTriggered.getValue().getPayloadAsMap()) .contains(entry("foo", 1), entry("oof", 2)); }
@Test public void shouldUseScopePayloadWhenApplyingOutputMappings() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", b -> b.zeebeTaskType("type").zeebeInput("$.oof", "$.baz")) .boundaryEvent("timer") .cancelActivity(true) .timerWithDuration("PT1S") .zeebeOutputBehavior(ZeebeOutputBehavior.merge) .endEvent("endTimer") .moveToActivity("task") .endEvent() .done(); testClient.deploy(workflow); testClient.createWorkflowInstance(PROCESS_ID, "{\"foo\": 1, \"oof\": 2}"); // when testClient.receiveTimerRecord("timer", TimerIntent.CREATED); brokerRule.getClock().addTime(Duration.ofMinutes(1)); awaitProcessCompleted(); // then final Record<WorkflowInstanceRecordValue> boundaryTriggered = testClient.receiveElementInState("timer", WorkflowInstanceIntent.ELEMENT_COMPLETED); assertThat(boundaryTriggered.getValue().getPayloadAsMap()) .contains(entry("foo", 1), entry("oof", 2)); }
.zeebeOutput("$.foo", "$.bar") .zeebeOutputBehavior(ZeebeOutputBehavior.merge) .endEvent("endTimer") .moveToActivity("task") .endEvent()
.zeebeOutput("$.foo", "$.bar") .zeebeOutputBehavior(ZeebeOutputBehavior.merge) .endEvent("endTimer") .moveToActivity("task") .endEvent()
.boundaryEvent("event") .message(m -> m.name("msg").zeebeCorrelationKey("$.key")) .endEvent("msgEnd") .moveToActivity("outerSubProcess") .endEvent()
.cancelActivity(true) .timerWithDuration("PT1S") .endEvent("endTimer") .moveToActivity("sub") .endEvent()
.boundaryEvent("event") .message(m -> m.name("msg").zeebeCorrelationKey("$.key")) .endEvent("msgEnd") .moveToActivity("outerSubProcess") .endEvent()
.cancelActivity(true) .timerWithDuration("PT1S") .endEvent("endTimer") .moveToActivity("sub") .endEvent()
.boundaryEvent( "event", b -> b.message(m -> m.zeebeCorrelationKey("$.orderId").name("message"))) .endEvent() .moveToActivity("task") .endEvent()