AnsweredAssumed Answered

Unable to signal the process

Question asked by rajivmoghe on Apr 13, 2016
Latest reply on May 3, 2016 by jbarrez
Hi,
This has probably been asked many times before, but I am stuck and cannot figure out what the problem is.
I'm using the spring boot activiti starter project (activiti v 5.17.1-SANPSHOT, and boot v 1.2.2.RELEASE) for this.

I have a process as below:
For the 'My Service Task' task, I have extended the AbstractBpmnActivityBehavior to override its execute and signal methods (here). The idea is that this task, on entry, calls an external service, and waits in the same place, until it receives a 'My Action Completed Signal', that comes from the external service.


<?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" xmlns:tns="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <signal id="myActionSignal" name="My Action Completed Signal" activiti:scope="processInstance"></signal>
  <message id="alertRcvd" name="alertRcvdMessage"></message>
  <message id="myActionMessage" name="My Action Completed Message"></message>
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="messagestartevent1" name="Message start">
      <messageEventDefinition messageRef="alertRcvd"></messageEventDefinition>
    </startEvent>
    <serviceTask id="mytask" name="My Service Task" activiti:async="true" activiti:delegateExpression="${myActionTask}"></serviceTask>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript" activiti:autoStoreVariables="false">
      <script>print("Hello World. Service call completed.");</script>
    </scriptTask>
    <userTask id="usertask1" name="User Task"></userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" sourceRef="messagestartevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="scripttask1" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="usertask1" targetRef="mytask"></sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="boundarysignal1" targetRef="scripttask1"></sequenceFlow>
    <boundaryEvent id="boundarysignal1" name="Action Completed Message" attachedToRef="mytask" cancelActivity="false">
      <signalEventDefinition signalRef="myActionSignal"></signalEventDefinition>
    </boundaryEvent>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="messagestartevent1" id="BPMNShape_messagestartevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="110.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mytask" id="BPMNShape_mytask">
        <omgdc:Bounds height="55.0" width="105.0" x="360.0" y="150.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundarysignal1" id="BPMNShape_boundarysignal1">
        <omgdc:Bounds height="30.0" width="30.0" x="420.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
        <omgdc:Bounds height="55.0" width="105.0" x="515.0" y="150.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="210.0" y="150.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="640.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="145.0" y="177.0"></omgdi:waypoint>
        <omgdi:waypoint x="210.0" y="177.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="620.0" y="177.0"></omgdi:waypoint>
        <omgdi:waypoint x="640.0" y="177.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="315.0" y="177.0"></omgdi:waypoint>
        <omgdi:waypoint x="360.0" y="177.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="435.0" y="220.0"></omgdi:waypoint>
        <omgdi:waypoint x="434.0" y="241.0"></omgdi:waypoint>
        <omgdi:waypoint x="570.0" y="241.0"></omgdi:waypoint>
        <omgdi:waypoint x="567.0" y="205.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


I am able to start the process by supplying an alertRcvdMessage via the ReST API by doing a POST to …/runtime/process-instances with the body

{
   "message":"alertRcvdMessage",
}

A call to the …/runtime/executions/12/activities shows the to be waiting in the My Task activity. However, when I try to signal the process using PUT …/runtime/executions/12 with the following

{
  "action":"signalEventReceived",
  "signalName":"My Action Completed Signal"
}

I seem to consistently run into a

{
  "timestamp": 1460549262927,
  "status": 500,
  "error": "Internal Server Error",
  "exception": "org.activiti.engine.ActivitiException",
  "message": "Execution '12' has not subscribed to a signal event with name 'My Action Completed Signal'.",
  "path": "/runtime/executions/12"
}

I tried this with both, signal, as well as message (although I'm aware that messages are primarily for inter-(business)process communication), but I still end up with the 'Execution has not subscribed to message event …' as above.

Can someone help? Is there anything grossly wrong in the BPM XML above?
Why is it that I can signal a start, but not the intermediate state?

Attachments

Outcomes