cancel
Showing results for 
Search instead for 
Did you mean: 

[ACT-250] send an arbitrary message to receiveTask

farrukh_najmi
Champ in-the-making
Champ in-the-making
(Moving this to ActvitiDevelopers …)

It appears that a receiveTask currently can only accept a signal (string) via the RuntimeService.signal() method.

IMHO, this is a fairly major limitation. I did not see an issue in JIRA for it so I have created one here:

http://jira.codehaus.org/browse/ACT-250

What are the current plans for this feature? Would the dev team like me to take a stab at the design / dev / test for this feature?
2 REPLIES 2

farrukh_najmi
Champ in-the-making
Champ in-the-making
Here is a summary of what I have so far as a patch diff over recent trunk bits to address this issue:

  • RuntimeService - Adde a signal() variant that allows passing a specific object

  • RuntimeServiceImpl - Added impl of new signal method. Uses existing SignalCmd capability to signal with arbitrary message object

  • ReceiveTaskActivity - Updated signal method to store the signal message object as a new instance var name dataOutput
The following is the actual patch so far. To apply the patch us "patch -p1 < patch.txt" where patch.txt contains teh text copied from patch code below…


diff -r 7afd0f3dfc29 modules/activiti-engine/src/main/java/org/activiti/engine/RuntimeService.java
— a/modules/activiti-engine/src/main/java/org/activiti/engine/RuntimeService.java Tue Oct 19 08:47:15 2010 -0400
+++ b/modules/activiti-engine/src/main/java/org/activiti/engine/RuntimeService.java Fri Oct 22 10:22:54 2010 -0400
@@ -168,6 +168,14 @@
    */
   void signal(String executionId);
  
+  /** Sends an external message to an activity instance that is waiting inside the given execution.
+   * @param executionId id of execution to signal, cannot be null.
+   * @param signalName the name identifying the signal. May be null
+   * @param message the message being delivered to activity instance
+   * @throws ActivitiException when no execution is found for the given executionId.
+   */
+  void signal(String executionId, String signalName, Object message);
+
   /** Find variables for an execution.
    * @param executionId id of execution, cannot be null.
    * @throws ActivitiException when no execution is found for the given executionId.  
diff -r 7afd0f3dfc29 modules/activiti-engine/src/main/java/org/activiti/engine/impl/RuntimeServiceImpl.java
— a/modules/activiti-engine/src/main/java/org/activiti/engine/impl/RuntimeServiceImpl.java Tue Oct 19 08:47:15 2010 -0400
+++ b/modules/activiti-engine/src/main/java/org/activiti/engine/impl/RuntimeServiceImpl.java Fri Oct 22 10:22:54 2010 -0400
@@ -99,6 +99,10 @@
     commandExecutor.execute(new SignalCmd(activityInstanceId, null, null));
   }

+  public void signal(String activityInstanceId, String signalName, Object message) {
+      commandExecutor.execute(new SignalCmd(activityInstanceId, signalName, message));
+  }
+
   public ProcessInstanceQuery createProcessInstanceQuery() {
     return new ProcessInstanceQueryImpl(commandExecutor);
   }
diff -r 7afd0f3dfc29 modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/ReceiveTaskActivity.java
— a/modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/ReceiveTaskActivity.java Tue Oct 19 08:47:15 2010 -0400
+++ b/modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/ReceiveTaskActivity.java Fri Oct 22 10:22:54 2010 -0400
@@ -27,12 +27,21 @@
  */
public class ReceiveTaskActivity extends TaskActivity {

+  private Object dataOutput = null;
+
   public void execute(ActivityExecution execution) throws Exception {
     // Do nothing: waitstate behavior
   }
  
   public void signal(ActivityExecution execution, String signalName, Object data) throws Exception {
+    this.dataOutput = data;
     leave(execution);
   }

+
+  /**
+   * @return the dataOutput of the receiveTask (if any)
+   */
+  public Object getDataOutput() {
+      return dataOutput;
+  } 
}

Am I in the right direction… Please critique.

Specifically, what I need help from someone is what needs to be done to lookup the dataOutput of the task when evaluating the conditionExpression on the outgoing sequenceFlows. Can any one more familiar with the code please help me over the hump on this. TIA.

I think initially we can work with existing support for JUEL as language for conditionExpression. However, in a second phase as perhaps a fix for http://jira.codehaus.org/browse/ACT-253 we should add support for any JSR 223 scripting language (including XPATH).

farrukh_najmi
Champ in-the-making
Champ in-the-making
Farrukh: whats the use case ? What would you be passing ?

Note that the current impl of the receive task is just a wait state.

Hi Joram, The use case is based on a specification I am writing at OASIS called ebXML RegRep 4. See draft regrep-rs.pdf in:

  http://www.oasis-open.org/committees/download.php/39762/regrep-spec-4.0-wd6-3.zip

Specifically see chapter 10 Governance Features and the section titled ReceiveWorkflowAction.

Here is the summary… The registry server provides a special message of type rim:WorkflowActionType (see rim.xsd in spec zip file) that can be used by clients to trigger a BPMN process within the server that governs changes to the object in the registry that it is governing. The WorkflowAction message has a action (string), various other attributes and elements, as well as arbitrary map of name/value pairs called slots. A slot could have a primitive value, a collection value or even complex values (e.g. maps).

The BPMN process needs to have a receiveTask based on the ReceiveWorkflowAction task pattern be followed by a sequenceFlow with a conditionExpresion where the expression is an XPATH expression on the documents that is the dataOutput of the receiveTask.

In summary, the need is to be able to wait for an arbitrary message in a receiveTask and then evaluate an XPATH condition on the message to proceeed out of the receiveTask to the next flow element.

Lastly, please note that I have attached a partial patch on this thread and have a specific question on it:

Specifically, what I need help from someone is what needs to be done to lookup the dataOutput of the task when evaluating the conditionExpression on the outgoing sequenceFlows.

Please advice how you would like me to proceed.