Throw Message Trigger in a subprocess

cancel
Showing results for 
Search instead for 
Did you mean: 
annie-acro
Member II

Throw Message Trigger in a subprocess

My usecase is that I want to execute the subprocess n number of times, where, n = number of items in the list. For each item, call doc verification service is called which in turn calls an external api. I need to wait for the response. When the response is received, throw a message signal and then update data. If no response received within 2 minutes, again, update data. The subprocess execution should be in parallel. 

The problem I'm facing is that I'm unable to throw a message signal from java code (call doc verification service). When I query, it gives null always.

My bpmn definition:

<?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:activiti="http://activiti.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.activiti.org/processdef" xmlns:modeler="http://activiti.com/modeler" modeler:version="1.0en" modeler:exportDateTime="20210511203009609" modeler:modelId="3004" modeler:modelVersion="1" modeler:modelLastUpdated="1620736483537">
<message id="hello" name="Hello Event"/>
<process id="documentProcess" name="documentProcess" isExecutable="true">
<startEvent id="startEvent1">
<extensionElements>
<modeler:editor-resource-id><![CDATA[startEvent1]]></modeler:editor-resource-id>
</extensionElements>
</startEvent>
<serviceTask id="getAuthenticationToken" name="get authentication token" activiti:class="com.application.verification.service.JavaDelegateServiceGetToken">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-42C8F57E-2EB7-4598-8A10-C47CFF153973]]></modeler:editor-resource-id>
</extensionElements>
</serviceTask>
<sequenceFlow id="sid-47DB8DC9-3741-4D03-B6CC-35B568E66172" sourceRef="startEvent1" targetRef="getAuthenticationToken">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-47DB8DC9-3741-4D03-B6CC-35B568E66172]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<sequenceFlow id="sid-A225EFD3-4A6B-44A4-B49C-00F2611CB1B1" sourceRef="getAuthenticationToken" targetRef="subProcess">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-A225EFD3-4A6B-44A4-B49C-00F2611CB1B1]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<subProcess id="subProcess" name="subProcess">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-E6A87C29-2296-41F3-8654-AFE279A0E94F]]></modeler:editor-resource-id>
</extensionElements>
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="applicantDetails" activiti:elementVariable="applicantDetail"/>
<serviceTask id="callDocVerificationService" name="Call Doc Verification Service" activiti:expression="${applicationService.sendRequest(execution,applicantDetail)}">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-E957C208-5E99-43EA-9FB4-0E9205439F28]]></modeler:editor-resource-id>
</extensionElements>
</serviceTask>
<eventBasedGateway id="sid-F63A77D6-D065-4D04-9468-C1694290677E">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-F63A77D6-D065-4D04-9468-C1694290677E]]></modeler:editor-resource-id>
</extensionElements>
</eventBasedGateway>
<intermediateCatchEvent id="timerEvent" name="Alert">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-429EC7BB-66C1-447B-A8F1-98F6EDB020B5]]></modeler:editor-resource-id>
</extensionElements>
<timerEventDefinition>
<timeDate>PT2M</timeDate>
</timerEventDefinition>
</intermediateCatchEvent>
<serviceTask id="sid-DFFF1B67-F34D-4E2A-AC66-501EF1203CB5" name="Update Data" activiti:class="com.application.verification.service.JavaDelegateServiceUpdate">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-DFFF1B67-F34D-4E2A-AC66-501EF1203CB5]]></modeler:editor-resource-id>
</extensionElements>
</serviceTask>
<startEvent id="sid-193122DC-24BE-492C-A478-2F5BD2EA2355">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-193122DC-24BE-492C-A478-2F5BD2EA2355]]></modeler:editor-resource-id>
</extensionElements>
</startEvent>
<endEvent id="sid-2616A1ED-A7BE-4F26-8DB5-A6D858092ABB">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-2616A1ED-A7BE-4F26-8DB5-A6D858092ABB]]></modeler:editor-resource-id>
</extensionElements>
</endEvent>
<intermediateCatchEvent id="catchMessage" name="catchMessage">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-363E0ED9-C441-401B-B312-34F74A1B17BC]]></modeler:editor-resource-id>
</extensionElements>
<messageEventDefinition messageRef="hello"/>
</intermediateCatchEvent>
<sequenceFlow id="sid-44A6D6D1-92AF-4DFF-8A0D-3BB3F1766C37" sourceRef="callDocVerificationService" targetRef="sid-F63A77D6-D065-4D04-9468-C1694290677E">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-44A6D6D1-92AF-4DFF-8A0D-3BB3F1766C37]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<sequenceFlow id="sid-2922C307-5F27-45D4-AFB0-D4BE8DDDACE4" sourceRef="timerEvent" targetRef="sid-DFFF1B67-F34D-4E2A-AC66-501EF1203CB5">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-2922C307-5F27-45D4-AFB0-D4BE8DDDACE4]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<sequenceFlow id="sid-E635DDD0-4D47-40C4-AD24-860967158F98" sourceRef="sid-193122DC-24BE-492C-A478-2F5BD2EA2355" targetRef="callDocVerificationService">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-E635DDD0-4D47-40C4-AD24-860967158F98]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<sequenceFlow id="sid-AE38FEA0-3BE4-40B4-A12C-1DFB90FD83A9" sourceRef="sid-DFFF1B67-F34D-4E2A-AC66-501EF1203CB5" targetRef="sid-2616A1ED-A7BE-4F26-8DB5-A6D858092ABB">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-AE38FEA0-3BE4-40B4-A12C-1DFB90FD83A9]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<sequenceFlow id="sid-F471CF28-B4BE-408C-B3BE-FC6D6BFCE541" sourceRef="catchMessage" targetRef="sid-DFFF1B67-F34D-4E2A-AC66-501EF1203CB5">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-F471CF28-B4BE-408C-B3BE-FC6D6BFCE541]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<sequenceFlow id="sid-4EF073E1-0303-45D7-9313-1C4BB88BE2E3" sourceRef="sid-F63A77D6-D065-4D04-9468-C1694290677E" targetRef="timerEvent">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-4EF073E1-0303-45D7-9313-1C4BB88BE2E3]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<sequenceFlow id="sid-CD809BBF-5313-4B46-8CF6-6D178B6278F7" sourceRef="sid-F63A77D6-D065-4D04-9468-C1694290677E" targetRef="catchMessage">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-CD809BBF-5313-4B46-8CF6-6D178B6278F7]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
</subProcess>
<serviceTask id="sid-BBEA915C-BD7C-4109-8CD6-C6C22346666C" name="Dispatch Data" activiti:class="com.application.verification.service.JavaDelegateServiceDispatch">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-BBEA915C-BD7C-4109-8CD6-C6C22346666C]]></modeler:editor-resource-id>
</extensionElements>
</serviceTask>
<sequenceFlow id="sid-708D26D3-7D7B-4032-A510-ABF2C7E26B18" sourceRef="subProcess" targetRef="sid-BBEA915C-BD7C-4109-8CD6-C6C22346666C">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-708D26D3-7D7B-4032-A510-ABF2C7E26B18]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
<endEvent id="sid-7F9B45F7-6010-4146-A0BD-60DA6EC43EDD">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-7F9B45F7-6010-4146-A0BD-60DA6EC43EDD]]></modeler:editor-resource-id>
</extensionElements>
</endEvent>
<sequenceFlow id="sid-AC953C7A-7637-4A9B-ACF7-A8EF4EB45F0A" sourceRef="sid-BBEA915C-BD7C-4109-8CD6-C6C22346666C" targetRef="sid-7F9B45F7-6010-4146-A0BD-60DA6EC43EDD">
<extensionElements>
<modeler:editor-resource-id><![CDATA[sid-AC953C7A-7637-4A9B-ACF7-A8EF4EB45F0A]]></modeler:editor-resource-id>
</extensionElements>
</sequenceFlow>
</process>
</definitions>
-----------------------------------------------------------------------------------------------


This is how I'm trying to throw message signal:
ExecutionQuery exeQuery = runtimeService.createExecutionQuery().processVariableValueEquals(applicantDetail.getDocumentsMetaData(), applicantDetail.getDocumentsMetaData());
Execution ex = exeQuery.messageEventSubscriptionName("Hello Event").singleResult();

here, ex is null.
runtimeService.messageEventReceived("Hello Event", ex.getId());