cancel
Showing results for 
Search instead for 
Did you mean: 

Rest api for send a 'signal with parameters'

danilo1
Champ in-the-making
Champ in-the-making
Hi,
The Receive Task can be waked up by a signal sent by code or api rest.

The code (current release 5.13) implements both :
- the simple service (  RuntimeService.signal(String executionId)    )  
- the extended service (   RuntimeService.signal(String executionId, Map<String,Object> processVariables)  )

In the new api-rest is exposed only the simple version and not the extended while in the legacy rest-api was exposed the complex too.
Could you expose the complex version in the next version?


I inspected the related class of the 5.13-alf-20130918 version (  org.activiti.rest.api.runtime.process.ExecutionResource.java ) and seems that it's enought add just the call :


  @Put
  public ExecutionResponse performExecutionAction(ExecutionActionRequest actionRequest) {
    if(!authenticate()) {
      return null;
    }
   
    Execution execution = getExecutionFromRequest();
   
    if(ExecutionActionRequest.ACTION_SIGNAL.equals(actionRequest.getAction())) {
       if(actionRequest.getVariables() != null) {                                                                                          //   <—–  ADDED
          ActivitiUtil.getRuntimeService().signal(execution.getId(), getVariablesToSet(actionRequest));        //   <—–  ADDED
        } else {                                                                                                                                              //   <—–  ADDED
                ActivitiUtil.getRuntimeService().signal(execution.getId());
        }                                                                                                                                                     //   <—–  ADDED
    } else if(ExecutionActionRequest.ACTION_SIGNAL_EVENT_RECEIVED.equals(actionRequest.getAction())) {
      if(actionRequest.getSignalName() == null) {
        throw new ActivitiIllegalArgumentException("Signal name is required");
      }
      if(actionRequest.getVariables() != null) {
        ActivitiUtil.getRuntimeService().signalEventReceived(actionRequest.getSignalName(), execution.getId(), getVariablesToSet(actionRequest));
      } else {
        ActivitiUtil.getRuntimeService().signalEventReceived(actionRequest.getSignalName(), execution.getId());
      }
    } else if(ExecutionActionRequest.ACTION_MESSAGE_EVENT_RECEIVED.equals(actionRequest.getAction())) {
      if(actionRequest.getMessageName() == null) {
        throw new ActivitiIllegalArgumentException("Message name is required");
      }
      if(actionRequest.getVariables() != null) {
        ActivitiUtil.getRuntimeService().messageEventReceived(actionRequest.getMessageName(), execution.getId(), getVariablesToSet(actionRequest));
      } else {
        ActivitiUtil.getRuntimeService().messageEventReceived(actionRequest.getMessageName(), execution.getId());
      }
    } else {
      throw new ActivitiIllegalArgumentException("Invalid action: '" + actionRequest.getAction() + "'.");
    }
   
    // Re-fetch the execution, could have changed due to action or even completed
    execution = ActivitiUtil.getRuntimeService().createExecutionQuery().executionId(execution.getId()).singleResult();
    if(execution == null) {
      // Execution is finished, return empty body to inform user
      setStatus(Status.SUCCESS_NO_CONTENT);
      return null;
    } else {
      return getApplication(ActivitiRestServicesApplication.class).getRestResponseFactory()
      .createExecutionResponse(this, execution);
    }
  }
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
5.13-alf-20130918 is not the main release… The issue with the signals is fixed on master and will be part of 5.14

danilo1
Champ in-the-making
Champ in-the-making
Thank you.