cancel
Showing results for 
Search instead for 
Did you mean: 

Execution query by messageEventSubscriptionName question

andy135790
Champ in-the-making
Champ in-the-making
Hi,

I have only one process instance running that has a boundary message event "testMessage" and a local variable "customerId" set to "1".

The definition look something like this:

<message id="testMessage" name="testMessage"></message>
<process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task1"></userTask>
    <sequenceFlow id="flow2" sourceRef="scripttask1" targetRef="usertask1"></sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script>execution.setVariable("customerId", "1")</script>
    </scriptTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <boundaryEvent id="message" name="testMessage" attachedToRef="usertask1" cancelActivity="true">
      <messageEventDefinition messageRef="testMessage"></messageEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow3" sourceRef="message" targetRef="endevent2"></sequenceFlow>
</process>

But I got null when I try to query this execution.

runtimeService.createExecutionQuery().messageEventSubscriptionName("testMessage").variableValueEqualsIgnoreCase("customerId", "1").singleResult()
This should work according to the user guide

Also I got different id when I try to query them separately.

def id1 = runtimeService.createExecutionQuery().messageEventSubscriptionName("testMessage").singleResult().id
def id2 = runtimeService.createExecutionQuery().variableValueEquals("customerId", "1").singleResult().id
assert id1 != id2

Anyone knows why is that?

Thanks in advance.
1 REPLY 1

andy135790
Champ in-the-making
Champ in-the-making
I also noticed that when I start this process there are two items created in the ACT_RU_EXECUTION table. One is the parent of the other one.
My guess is that the child is the message handler. But I don't know how to retrieve the execution ID by both the massage name and variable value.