My bpmn file is as follows: Addition.bpmn
I am using receive task so that i can use RuntimeService, I am starting my process in sayHello class as follows:
public void sayHello(ProcessEngine processEngine) {
try {
System.out.println("inside postdeploy ");
variables.put("a", 2);
variables.put("b", 5);
variables.put("c", 0);
ProcessInstance instance= processEngine.getRuntimeService().startProcessInstanceByKey("Process_2", variables);
variables.put("c",processEngine.getRuntimeService().getVariable(instance.getId(), "c"));
Execution execution = processEngine.getRuntimeService().createExecutionQuery()
.processInstanceId(instance.getId())
.activityId("ReceiveTask_16nulbx")
.singleResult();
processEngine.getRuntimeService().signal(execution.getId());
I set my c variable in Calculator class which is implementing by my service task as follows:
public class Calculator implements JavaDelegate {
public void execute(DelegateExecution exe) throws Exception {
System.out.println("Inside calculator again");
Integer x = (Integer) exe.getVariable("a");
Integer y = (Integer) exe.getVariable("b");
int add = x+y;
System.out.println("Addition is"+add);
exe.setVariable("c", add);
}
The problem is my process instance is not ended after this. My question is how can i end my Process instance after getting my c variable?