Is it possible to use same kafka topic for event-registry's start event and boundary event

Hi,
I am trying to integrate the event-registry boundary event and start event. There’s a use case where I need to use the same Kafka topic for both the boundary and start event. Is there any way to do so? Also, Do I need to create a different channel definition file(with the same topic name) and event-definition file or Can I just attach my boundary event to the same channel def and event def as of start-event.

Thanks

Both can use the same channel/event key and will be called.

Please allow me to explain my use case, I want to use an event E1 as a start event for a process instance. Now after performing 2 service tasks I want to wait for another event E2 from the same topic which I want it to land on boundary event registry. Because if it lands on the start event it will start another process instance. Please let me know if I am missing something here or if my understanding of the event registry is lacking.

BPMN FILE

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef">
  <process id="POC_subProcess" name="POC_subProcess" isExecutable="true">
    <startEvent id="message1" name="message1">
      <extensionElements>
        <flowable:eventType xmlns:flowable="http://flowable.org/bpmn"><![CDATA[boundaryEvent]]>. </flowable:eventType>
    <flowable:keyDetectionType xmlns:flowable="http://flowable.org/bpmn"><![CDATA[fixedValue]]></flowable:keyDetectionType>
    <flowable:keyDetectionValue xmlns:flowable="http://flowable.org/bpmn"><![CDATA[boundaryEvent]]></flowable:keyDetectionValue>
    <flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn" source="userId" sourceType="string" target="userId"></flowable:eventOutParameter>
  </extensionElements>
</startEvent>
<sequenceFlow id="sid-8E37C3E7-9E84-4B47-9936-684D3841CAF5" sourceRef="message1" targetRef="task1"></sequenceFlow>
<serviceTask id="task3" name="task3" flowable:expression="${task3.execute()}"></serviceTask>
<sequenceFlow id="sid-F14402AC-CA3A-4978-96A4-6457969D16FE" sourceRef="m2" targetRef="task3"></sequenceFlow>
<intermediateCatchEvent id="timer1" name="timer1">
  <timerEventDefinition>
    <timeDuration>PT5M</timeDuration>
  </timerEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="sid-70A41B8E-A1FA-4212-B555-1A636AD42B28" sourceRef="task3" targetRef="timer1"></sequenceFlow>
<endEvent id="sid-C15AF029-74C2-4926-8690-8E525E3F2AD5"></endEvent>
<sequenceFlow id="sid-89979B10-DA49-43AD-91A9-5AFDD293D5AC" sourceRef="timer1" targetRef="sid-C15AF029-74C2-4926-8690-8E525E3F2AD5"></sequenceFlow>
<serviceTask id="task1" name="task1" flowable:class="com.baeldung.service.SendMailService"></serviceTask>
<subProcess id="sid-8C64ECFC-A701-4FF6-8E00-E6181B2A2FEC" name="subProcess">
  <serviceTask id="task2" name="task2" flowable:class="com.baeldung.service.SendMailService"></serviceTask>
  <intermediateCatchEvent id="timer2" name="timer2">
    <timerEventDefinition>
      <timeDuration>PT5M</timeDuration>
    </timerEventDefinition>
  </intermediateCatchEvent>
  <endEvent id="sid-5C170307-4B3A-4DBD-9E84-045CA762F87C"></endEvent>
  <startEvent id="sid-28EF8B29-AD68-4554-95ED-51F32496F16E" flowable:formFieldValidation="true"></startEvent>
  <sequenceFlow id="sid-7F6DE6A2-EFEB-489C-83F6-D264E3C0EA8D" sourceRef="timer2" targetRef="sid-5C170307-4B3A-4DBD-9E84-045CA762F87C"></sequenceFlow>
  <sequenceFlow id="sid-D9424481-FEB6-42AE-AD15-C28FD4FD7E60" sourceRef="task2" targetRef="timer2"></sequenceFlow>
  <sequenceFlow id="sid-36C98DC3-BB7E-4E28-9490-9B5717758C66" sourceRef="sid-28EF8B29-AD68-4554-95ED-51F32496F16E" targetRef="task2"></sequenceFlow>
</subProcess>
<sequenceFlow id="sid-61F435B1-CCC9-452B-A883-D5A8DCD8344B" sourceRef="task1" targetRef="sid-8C64ECFC-A701-4FF6-8E00-E6181B2A2FEC"></sequenceFlow>
<boundaryEvent id="m2" name="m2" attachedToRef="sid-8C64ECFC-A701-4FF6-8E00-E6181B2A2FEC">
  <extensionElements>
    <flowable:eventType xmlns:flowable="http://flowable.org/bpmn"><![CDATA[boundaryEvent]]></flowable:eventType>
    <flowable:keyDetectionType xmlns:flowable="http://flowable.org/bpmn"><![CDATA[fixedValue]]></flowable:keyDetectionType>
    <flowable:keyDetectionValue xmlns:flowable="http://flowable.org/bpmn"><![CDATA[boundaryEvent]]></flowable:keyDetectionValue>
    <!--        <flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn" source="userId" sourceType="string" target="userId"></flowable:eventOutParameter>-->
    <!--        <flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn" source="eventType" sourceType="string" target="eventType"></flowable:eventOutParameter>-->
    <!--        <flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn" source="name" sourceType="string" target="name"></flowable:eventOutParameter>-->
    <flowable:eventCorrelationParameter xmlns:flowable="http://flowable.org/bpmn" name="userId" type="string" value="${userId}"></flowable:eventCorrelationParameter>

  </extensionElements>
    </boundaryEvent>
    <endEvent id="sid-4446D45E-BB49-4FED-8AC8-B71A8FE46567"></endEvent>
    <sequenceFlow id="sid-382F2B8D-8C7C-4224-9ECE-0FCDDB846D14" sourceRef="sid-8C64ECFC-A701-4FF6-8E00-E6181B2A2FEC" targetRef="sid-4446D45E-BB49-4FED-8AC8-B71A8FE46567"></sequenceFlow>
   </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_POC_subProcess">
<bpmndi:BPMNPlane bpmnElement="POC_subProcess" id="BPMNPlane_POC_subProcess">
  <bpmndi:BPMNShape bpmnElement="message1" id="BPMNShape_message1">
    <omgdc:Bounds height="30.0" width="30.5" x="150.0" y="160.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="task3" id="BPMNShape_task3">
    <omgdc:Bounds height="80.0" width="100.0" x="353.42973925703905" y="285.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="timer1" id="BPMNShape_timer1">
    <omgdc:Bounds height="31.0" width="31.0" x="585.0" y="309.5"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="sid-C15AF029-74C2-4926-8690-8E525E3F2AD5" id="BPMNShape_sid-C15AF029-74C2-4926-8690-8E525E3F2AD5">
    <omgdc:Bounds height="28.0" width="28.0" x="741.0" y="311.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="task1" id="BPMNShape_task1">
    <omgdc:Bounds height="80.0" width="100.0" x="249.0" y="135.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="sid-8C64ECFC-A701-4FF6-8E00-E6181B2A2FEC" id="BPMNShape_sid-8C64ECFC-A701-4FF6-8E00-E6181B2A2FEC">
    <omgdc:Bounds height="112.0" width="464.0" x="349.0" y="18.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="task2" id="BPMNShape_task2">
    <omgdc:Bounds height="80.0" width="100.0" x="465.0" y="35.5"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="timer2" id="BPMNShape_timer2">
    <omgdc:Bounds height="31.0" width="31.0" x="630.0" y="60.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="sid-5C170307-4B3A-4DBD-9E84-045CA762F87C" id="BPMNShape_sid-5C170307-4B3A-4DBD-9E84-045CA762F87C">
    <omgdc:Bounds height="28.0" width="28.0" x="712.0" y="61.5"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="sid-28EF8B29-AD68-4554-95ED-51F32496F16E" id="BPMNShape_sid-28EF8B29-AD68-4554-95ED-51F32496F16E">
    <omgdc:Bounds height="30.0" width="30.0" x="375.0" y="60.5"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="m2" id="BPMNShape_m2">
    <omgdc:Bounds height="30.0" width="30.0" x="388.42973925703905" y="115.18344453124246"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="sid-4446D45E-BB49-4FED-8AC8-B71A8FE46567" id="BPMNShape_sid-4446D45E-BB49-4FED-8AC8-B71A8FE46567">
    <omgdc:Bounds height="28.0" width="28.0" x="900.0" y="60.0"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNEdge bpmnElement="sid-7F6DE6A2-EFEB-489C-83F6-D264E3C0EA8D" id="BPMNEdge_sid-7F6DE6A2-EFEB-489C-83F6-D264E3C0EA8D">
    <omgdi:waypoint x="661.9496949595359" y="75.90000191247813"></omgdi:waypoint>
    <omgdi:waypoint x="712.0002652094158" y="75.58718601457386"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-61F435B1-CCC9-452B-A883-D5A8DCD8344B" id="BPMNEdge_sid-61F435B1-CCC9-452B-A883-D5A8DCD8344B">
    <omgdi:waypoint x="299.0" y="135.0"></omgdi:waypoint>
    <omgdi:waypoint x="299.0" y="74.0"></omgdi:waypoint>
    <omgdi:waypoint x="348.99999999999557" y="74.0"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-70A41B8E-A1FA-4212-B555-1A636AD42B28" id="BPMNEdge_sid-70A41B8E-A1FA-4212-B555-1A636AD42B28">
    <omgdi:waypoint x="453.3797392570282" y="325.12641072551145"></omgdi:waypoint>
    <omgdi:waypoint x="585.0" y="325.4595082029713"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-382F2B8D-8C7C-4224-9ECE-0FCDDB846D14" id="BPMNEdge_sid-382F2B8D-8C7C-4224-9ECE-0FCDDB846D14">
    <omgdi:waypoint x="812.9499999999872" y="74.0"></omgdi:waypoint>
    <omgdi:waypoint x="900.0" y="74.0"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-89979B10-DA49-43AD-91A9-5AFDD293D5AC" id="BPMNEdge_sid-89979B10-DA49-43AD-91A9-5AFDD293D5AC">
    <omgdi:waypoint x="616.9499176544086" y="325.44805221624523"></omgdi:waypoint>
    <omgdi:waypoint x="741.00007131551" y="325.04529212130365"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-36C98DC3-BB7E-4E28-9490-9B5717758C66" id="BPMNEdge_sid-36C98DC3-BB7E-4E28-9490-9B5717758C66">
    <omgdi:waypoint x="404.94999883049303" y="75.5"></omgdi:waypoint>
    <omgdi:waypoint x="464.99999999997914" y="75.5"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-8E37C3E7-9E84-4B47-9936-684D3841CAF5" id="BPMNEdge_sid-8E37C3E7-9E84-4B47-9936-684D3841CAF5">
    <omgdi:waypoint x="180.94999886826562" y="175.0"></omgdi:waypoint>
    <omgdi:waypoint x="249.0" y="175.0"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-F14402AC-CA3A-4978-96A4-6457969D16FE" id="BPMNEdge_sid-F14402AC-CA3A-4978-96A4-6457969D16FE">
    <omgdi:waypoint x="403.42973925703905" y="145.13344404967154"></omgdi:waypoint>
    <omgdi:waypoint x="403.42973925703905" y="285.0"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="sid-D9424481-FEB6-42AE-AD15-C28FD4FD7E60" id="BPMNEdge_sid-D9424481-FEB6-42AE-AD15-C28FD4FD7E60">
    <omgdi:waypoint x="564.9499999999581" y="75.5"></omgdi:waypoint>
    <omgdi:waypoint x="630.0" y="75.5"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

In this after E1 event, when I produce event E2 it always lands on the start event. I want it to land only on the boundary event. I have also tried creating two different channel defs with same topic and 2 diff event defs one for the boundary event in which I am adding a correlation parameter(userId) and other for the start event. But it didn’t work.

Thanks And Regards

How is your channel configured?

If you have different events arriving on the same topic you need to somehow link the data coming on the topic with the appropriate event.

The options you have are:

  • fixedValue - fix key of the event (this means the channel is listening for a single event only)
  • jsonField - the event key is in the field of the json body
  • jsonPointerExpression - the event key is in the location of the json body the pointer points to
  • xmlXPathExpression - the event key is in the location of the xml body the xml path points to
  • delegateExpression - a custom bean of type InboundEventKeyDetector