cancel
Showing results for 
Search instead for 
Did you mean: 

Signal Data is null in ReceiveTaskActivityBehavior

symphony_person
Champ in-the-making
Champ in-the-making
I have simple process with a Service Task backed by a ReceiveTaskActivityBehavior. It will invoke a command in a remote machine and wait for a notification. When I send a signal from outside, it hits the signal method but the data is null. Please help.

test.bpmn
———–


<?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/test">
  <process id="test1" name="test1" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="org.activiti.CustomTask"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
  </process>
 
</definitions>



ReceiveTaskActivityBehavior
————————

public class CustomTask extends ReceiveTaskActivityBehavior {

    private static final long serialVersionUID = 2945313111593357836L;

    /*
     * (non-Javadoc)
     *
     * @see
     * org.activiti.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior#execute
     * (org.activiti.engine.impl.pvm.delegate.ActivityExecution)
     */
    @Override
    public void execute(ActivityExecution execution) throws Exception {
        Command command = new Command();
        command.doSomething(execution.getEngineServices().getRuntimeService(), execution);

    }

    /*
     * (non-Javadoc)
     *
     * @see
     * org.activiti.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior#signal
     * (org.activiti.engine.impl.pvm.delegate.ActivityExecution,
     * java.lang.String, java.lang.Object)
     */
    @Override
    public void signal(ActivityExecution execution, String signalName, Object data) throws Exception {
        //Fails here
        Assert.assertEquals(data != null, true);
        leave(execution);
    }

}


Command.java
————-


public class Command {

    public void doSomething(RuntimeService runtimeService, ActivityExecution execution) {
        System.out.println("done");
        //notify
        Map<String, Object> signalData = new HashMap<String, Object>();
        runtimeService.signal(execution.getId(), signalData);
       
    }

}
2 REPLIES 2

trademak
Star Contributor
Star Contributor
The signalData is stored as process variables on the execution, it's not the signal data object. So you can get the Map content with the execution getVariable method based on the map key.

Best regards,

symphony_person
Champ in-the-making
Champ in-the-making
Thanks. I verified its set in the process variables. But the signalData parameter was confusing.