cancel
Showing results for 
Search instead for 
Did you mean: 

Figure out if an execution is signalable

sdeb
Champ in-the-making
Champ in-the-making
Is there a way to somehow check if an execution will throw 'ActivitiException: this activity doesn't accept signals' before actually doing a signal? We would like to be able to handle this error in our project, but in our case cannot use exception handling.

Thanks in advance!
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
in case it's a signal-catching event with a signalRef associated in the BPMN.xml, you can do an execution query and ask for all signal event subscriptions:


/**
   * Only select executions which have a signal event subscription
   * for the given signal name.
   *
   * (The signalName is specified using the 'name' attribute of the signal element
   * in the BPMN 2.0 XML.)
   *
   * @param signalName the name of the signal the execution has subscribed to
   */
  ExecutionQuery signalEventSubscriptionName(String signalName);

For receive-tasks, this is not as straight-forward. One option is, if you know what activityId you're expecting to be "signallable", you can query for all executions waiting in that activity. Or, if you don't know what acitvityId it will be, you can loop over the possible executions matching and cross-reference the activityId with the BPMNModel associated with the process-definition (use managementService to get the model, these are cached in the engine, so no overhead when getting the same model twice).