cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to signal the process

rajivmoghe
Champ in-the-making
Champ in-the-making
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?
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
You are mixing the BPMN 'signal' concept with the 'signal' in the core engine.
It has nothing to do with each other. The latter is also renamed to 'trigger' in version 6.
So to continue your custom task, you simply need to call the runtimeService.signal (NOT signalEventReceived) method to continue the process (exactly the same as when using a receive task).

rajivmoghe
Champ in-the-making
Champ in-the-making
Hi Joram,

Thanks for this. I tried this out by using
{
  "action":"signal",
  "signalName":"Some Signal"
}
.

In the MyServiceTask.java I also have the signal method as follows:
  public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
   System.out.println("SignalName "+ signalName +"\n"+ "Signal Data  "+ signalData);
    leave(execution);
  }

On debug, I traced the ReST call to this routes this call to RuntimeService's signal(String execId, Map procVars) method, that creates a SignalCmd with the signalName and signalData as nulls. Which means that in my service task, I do not have access to the signal name (Or is that the triggerName in 6.0 onwards?).

Q: Is there any way I can have that, short of rewriting my own wrapper on the RuntimeService and a new ReST endpoint for this?

jbarrez
Star Contributor
Star Contributor
"Which means that in my service task, I do not have access to the signal name (Or is that the triggerName in 6.0 onwards?)."

Yes, signal in v5 = trigger in v6. A 'signal' in v5 speak in this context is effectively a 'go ahead' at a wait state.

"Is there any way I can have that, short of rewriting my own wrapper on the RuntimeService and a new ReST endpoint for this? "

Maybe there is a way to use process variables for this purpose? Although it doesn't match perfectly.

rajivmoghe
Champ in-the-making
Champ in-the-making
So I really cannot have the following ? As in herepublic void signal(ActivityExecution execution, String signalName, Object signalData){
     if(signalName.equals("serviceCompletedSignal")){
      add signalData to procVars;
      leave();
     }
     else{// signalName.equals("allData is available")
      add allData to procVars;
      execute();
     } 

since this signal (v6 trigger) is merely an unconditional 'continue forward' to the instance?
And also the 'signal' of the method name and 'signalName' in the paramlist refer to two different concepts?

jbarrez
Star Contributor
Star Contributor
" is merely an unconditional 'continue forward' to the instance"

Yes.

"And also the 'signal' of the method name and 'signalName' in the paramlist refer to two different concepts?"

In the default implementations shipped with the engine, yes. But you can use it for whatever purpose in your custom code of course.