Send Event is not getting triggered when a event response comes

Hi All,

The following is my xml

    <?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="Examples">
  <process id="eventTest" name="Process to test events" isExecutable="true">
    <startEvent id="theStart">
      <extensionElements>
        <flowable:eventType xmlns:flowable="http://flowable.org/bpmn"><![CDATA[carparkEnterEvent]]></flowable:eventType>
        <flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn" source="vehicleNumber" sourceType="string" target="vehicleNumber"></flowable:eventOutParameter>
        <flowable:eventOutParameter xmlns:flowable="http://flowable.org/bpmn" source="carpark" sourceType="string" target="carpark"></flowable:eventOutParameter>
      </extensionElements>
    </startEvent>
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask"></sequenceFlow>
    <serviceTask id="theTask" name="event test task" flowable:async="true" flowable:delegateExpression="${testTask}"></serviceTask>
    <sequenceFlow id="flow2" sourceRef="theTask" targetRef="sendTestEvent"></sequenceFlow>
    <endEvent id="theEnd"></endEvent>
    <serviceTask id="sendTestEvent" name="send test event and wait for result" flowable:type="send-event" flowable:triggerable="true">
      <extensionElements>
        <flowable:eventType><![CDATA[sendEvent]]></flowable:eventType>
        <flowable:triggerEventType><![CDATA[sendEventResult]]></flowable:triggerEventType>
        <flowable:eventInParameter sourceExpression="${carpark}" target="carpark" targetType="string"></flowable:eventInParameter>
        <flowable:eventInParameter sourceExpression="${vehicleNumber}" target="vehicleNumber" targetType="string"></flowable:eventInParameter>
        <flowable:eventOutParameter source="carpark" sourceType="string" target="carpark"></flowable:eventOutParameter>
        <flowable:eventOutParameter source="vehicleNumber" sourceType="string" target="vehicleNumber"></flowable:eventOutParameter>
        <flowable:triggerEventCorrelationParameter xmlns:flowable="http://flowable.org/bpmn" name="carpark" type="string" value="carpark"></flowable:triggerEventCorrelationParameter>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="sid-71CB497F-69A2-4F5C-B71F-2CF67D95C87C" sourceRef="sendTestEvent" targetRef="sid-3769205C-80F8-4368-828B-A24ACCB4ED23"></sequenceFlow>
    <serviceTask id="sid-3769205C-80F8-4368-828B-A24ACCB4ED23" name="last task" flowable:async="true" flowable:delegateExpression="${testTask}"></serviceTask>
    <sequenceFlow id="sid-23AFBF1E-FC7F-4B7B-A37D-CC80D3217265" sourceRef="sid-3769205C-80F8-4368-828B-A24ACCB4ED23" targetRef="theEnd"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_eventTest">
    <bpmndi:BPMNPlane bpmnElement="eventTest" id="BPMNPlane_eventTest">
      <bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart">
        <omgdc:Bounds height="30.0" width="30.5" x="0.0" y="115.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="theTask" id="BPMNShape_theTask">
        <omgdc:Bounds height="60.0" width="100.0" x="80.0" y="100.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="theEnd" id="BPMNShape_theEnd">
        <omgdc:Bounds height="28.0" width="28.0" x="585.0" y="116.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sendTestEvent" id="BPMNShape_sendTestEvent">
        <omgdc:Bounds height="80.0" width="100.0" x="225.0" y="90.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-3769205C-80F8-4368-828B-A24ACCB4ED23" id="BPMNShape_sid-3769205C-80F8-4368-828B-A24ACCB4ED23">
        <omgdc:Bounds height="60.0" width="100.0" x="390.0" y="100.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="30.449973236872857" y="130.0"></omgdi:waypoint>
        <omgdi:waypoint x="42.0" y="130.0"></omgdi:waypoint>
        <omgdi:waypoint x="42.0" y="130.0"></omgdi:waypoint>
        <omgdi:waypoint x="79.99999999997692" y="130.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="179.94999999999072" y="130.0"></omgdi:waypoint>
        <omgdi:waypoint x="224.99999999998067" y="130.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-23AFBF1E-FC7F-4B7B-A37D-CC80D3217265" id="BPMNEdge_sid-23AFBF1E-FC7F-4B7B-A37D-CC80D3217265">
        <omgdi:waypoint x="489.95000000000005" y="130.0"></omgdi:waypoint>
        <omgdi:waypoint x="585.0" y="130.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-71CB497F-69A2-4F5C-B71F-2CF67D95C87C" id="BPMNEdge_sid-71CB497F-69A2-4F5C-B71F-2CF67D95C87C">
        <omgdi:waypoint x="324.94999999999976" y="129.71441320838912"></omgdi:waypoint>
        <omgdi:waypoint x="389.9999999999981" y="129.34286479250335"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

These are my event files

{
  "key": "carparkEnterEvent",
  "name": "Carpark Enter",
  "inboundChannelKeys": [
    "carparkenterChannel"
  ],
  "correlationParameters": [],
  "payload": [
    {
      "name": "vehicleNumber",
      "type": "string"
    },
    {
      "name": "carpark",
      "type": "string"
    }
  ]
}

{
  "key": "sendEvent",
  "name": "Send Event",
  "outboundChannelKeys": [
      "sendEventOutboundChannel"
   ],
  "correlationParameters": [],
  "payload": [
    {
      "name": "vehicleNumber",
      "type": "string"
    },
    {
      "name": "carpark",
      "type": "string"
    }
  ]
}

{
  "key": "sendEventResult",
  "name": "Send Event Result",
  "inboundChannelKeys": [
      "sendEventResultChannel"
    ],
  "correlationParameters": [
    {
      "name": "carpark",
      "type": "string"
    }
  ],
  "payload": [
    {
      "name": "vehicleNumber",
      "type": "string"
    },
    {
      "name": "carpark",
      "type": "string"
    }
  ]
}

And these are my channel files

{
  "key": "carparkenterChannel",
  "name": "Carpark Enter channel",
  "description": "Carpark Enter Channel",
  "channelType": "inbound",
  "type": "kafka",
  "deserializerType": "json",
  "channelEventKeyDetection": {
    "fixedValue": "carparkEnterEvent"
  },
  "topics": ["LPRS_CARPARK_ENTER_JSON"]
}

{
  "key": "sendEventOutboundChannel",
  "name": "Send Event Outbound channel",
  "description": "Send Event Outbound channel",
  "channelType": "outbound",
  "type": "kafka",
  "serializerType": "json",
  "topic": "SEND_EVENT"
}

{
  "key": "sendEventResultChannel",
  "name": "Send Event Result channel",
  "description": "Send Event Result Channel",
  "channelType": "inbound",
  "type": "kafka",
  "deserializerType": "json",
  "channelEventKeyDetection": {
    "fixedValue": "sendEventResult"
  },
  "topics": ["SEND_EVENT_RESULT"]
}

I can trigger the process by sending a message to LPRS_CARPARK_ENTER topic and the send-event svc task is also producing a message at SEND_EVENT topic. But when I am pushing a message to SEND_EVENT_RESULT topic to simulate a response, the svc task is not triggered and the process just sits there and does not move to the last task before the end event

Please help and thanks all in advance.

Hey @sukalpo,

How does the message you are pushing to SEND_EVENT_RESULT look like?

The “send test event and wait for result” task will wait for a message that has a carpark property with value carpark.

Is the message consumed by the Flowable consumer? You can put a breakpoint in KafkaChannelMessageListenerAdapter#onMessage(ConsumerRecord) and wait for the message to arrive.

Cheers,
Filip

Hi @filiphr,

I am using the below to the topic through a rest proxy

{
	"records": [
		{
			"value": {
				"vehicleNumber": "123",
				"carpark": "2A"
			}
		}
	]
}

I dont have a flowable consumer. I am expecting that as soon as the send-event task gets the messages from the topic it will go to the n ext task which is “the last task”. I will put a breakpoint and let you know.

Hey @sukalpo,

So the value of carpark is 2A. However, your “send test event and wait for result” should only be triggered when the value of carpark is carpark

That is coming from

<flowable:triggerEventCorrelationParameter name="carpark" type="string" value="carpark"></flowable:triggerEventCorrelationParameter>

What you probably want is to use the carpark variable from the process instance. For that you need to use an expression like ${carpark}.

Your XML should look like:

<flowable:triggerEventCorrelationParameter name="carpark" type="string" value="${carpark}"></flowable:triggerEventCorrelationParameter>

Ah ok. Let me quickly do the change and test this out. Loads of thanks to you!