AnsweredAssumed Answered

User Task with boundary message event

Question asked by boekhold on Feb 19, 2015
Latest reply on Feb 28, 2015 by jbarrez
Hi,

(see below for process definition, as generated by Activiti Explorer from 5.17)

I have a process with a User Task "Approve", and on that user task I have configured a Boundary Message Event, waiting for an "InterruptMessage". I'm trying to trigger this Boundary Message Event based on Message Name and ProcessInstanceId as follows:

        Execution execution = processEngine.getRuntimeService().createExecutionQuery()
                .processInstanceId(processInstanceId)
                .messageEventSubscriptionName(messageName)
                .singleResult();

        processEngine.getRuntimeService().messageEventReceived(messageName, execution.getId(), vars);

This consistently fails weirdly enough, even though I'm sure I'm using the correct value for processInstanceId.

(1) Is there anything obviously wrong with this approach?
(2) I noticed in the XML version of the BPMN model that cancelActivity="false" and there doesn't seem to be any way from the Modeler to switch it to "true"? The user guide says that "left side" is non-interrupting, "right side" is interrupting, but that doesn't seem to make any difference for me.

Maarten

<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/processdef">
  <message id="InterruptMessage" name="InterruptMessage"></message>
  <process id="FFCBPMDemo" name="FFCBPMDemo" isExecutable="true">
    <startEvent id="start" name="FFCBPM Start" activiti:initiator="initiator"></startEvent>
    <endEvent id="end" name="end"></endEvent>
    <sequenceFlow id="sequenceFlow2" sourceRef="TOFFC" targetRef="end"></sequenceFlow>
    <serviceTask id="TOFFC" name="TOFFC" activiti:delegateExpression="${FFCFlowStarterService}"></serviceTask>
    <scriptTask id="setVars" name="Set FFC Variables" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script>execution.setVariable("FFCInstance", "BPMDemo")
execution.setVariable("FFCFlowName", "WriteFile")

// Not used, the BPMFlowStarterActivity uses a process
// variable called 'data' (which just happens to be our
// input as well, so effectively we do a 1-to-1 copy)
def payload = '''\
This is a test message from a groovy script
in a ScriptTask'''

execution.setVariable("payload", payload.stripIndent())</script>
    </scriptTask>
    <sequenceFlow id="sid-F3C16836-8B56-4B08-A88A-1D78EB1640B1" sourceRef="setVars" targetRef="TOFFC"></sequenceFlow>
    <userTask id="Approve" name="Approve" activiti:assignee="kermit"></userTask>
    <sequenceFlow id="sid-ACF18CC9-27A2-4CB9-A3DD-87BDAA23BCCA" sourceRef="Approve" targetRef="setVars"></sequenceFlow>
    <sequenceFlow id="sequenceFlow1" sourceRef="start" targetRef="Approve"></sequenceFlow>
    <sequenceFlow id="sid-61BCA3DA-A81C-4239-B32A-B2F52D4104AC" sourceRef="Approve" targetRef="setVars"></sequenceFlow>
    <sequenceFlow id="sid-B9A579B4-E1A7-4744-90C3-3924F15DFEEB" sourceRef="Interrupt" targetRef="setVars"></sequenceFlow>
    <boundaryEvent id="Interrupt" name="Interrupt" attachedToRef="Approve" cancelActivity="false">
      <messageEventDefinition messageRef="InterruptMessage"></messageEventDefinition>
    </boundaryEvent>
  </process>

Outcomes