Receive Task and REST API

I’m new to Flowable and I’m trying to get a simple BPMN flow up and running with a message receive task. I’m trying to trigger the event via the REST API using the execution id but I’m having trouble which I’m sure is just my lack of knowledge.

I have flowable deployed in docker using the flowable/flowable-rest image with postgres:9.6-alpine as the backend.

Here are the relevant parts of my process definition:

<process id="test" name="test" isExecutable="true">
    <startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
    <receiveTask id="sid-48E45835-B603-45FE-87DB-271079B1CA24" name="WaitForEvent1">
      <extensionElements>
        <flowable:eventType xmlns:flowable="http://flowable.org/bpmn"><![CDATA[EventKey]]></flowable:eventType>
        <flowable:eventName xmlns:flowable="http://flowable.org/bpmn"><![CDATA[EventName]]></flowable:eventName>
      </extensionElements>
    </receiveTask>
    <endEvent id="sid-C07823C5-5245-4ADB-9B9A-B600A7EE56A5"></endEvent>
    <sequenceFlow id="sid-1BE97631-EC89-47DC-87C3-C4E6988608AA" sourceRef="sid-48E45835-B603-45FE-87DB-271079B1CA24" targetRef="sid-C07823C5-5245-4ADB-9B9A-B600A7EE56A5"></sequenceFlow>
    <sequenceFlow id="sid-AF281EC9-759F-4E38-BB8A-259914F54125" sourceRef="startEvent1" targetRef="sid-48E45835-B603-45FE-87DB-271079B1CA24"></sequenceFlow>
  </process>

Once the process instance is running I can see the event subscription in the REST API, but the eventName is null. Not sure why but I think this is the root of the problem outlined below.

{
    "data": [
        {
            "id": "868576e0-79f3-11ec-99f8-0242c0a87006",
            "url": "http://thud:8081/flowable-rest/service/runtime/event-subscriptions/868576e0-79f3-11ec-99f8-0242c0a87006",
            "eventType": "EventKey",
            "eventName": null,
            "activityId": "sid-48E45835-B603-45FE-87DB-271079B1CA24",
            "executionId": "868528bc-79f3-11ec-99f8-0242c0a87006",
            "executionUrl": "http://thud:8081/flowable-rest/service/runtime/executions/868528bc-79f3-11ec-99f8-0242c0a87006",
            "processInstanceId": "868528ba-79f3-11ec-99f8-0242c0a87006",
            "processInstanceUrl": "http://thud:8081/flowable-rest/service/runtime/process-instances/868528ba-79f3-11ec-99f8-0242c0a87006",
            "processDefinitionId": "test:4:24e56619-79f3-11ec-99f8-0242c0a87006",
            "processDefinitionUrl": "http://thud:8081/flowable-rest/service/repository/process-definitions/test:4:24e56619-79f3-11ec-99f8-0242c0a87006",
            "scopeId": null,
            "scopeType": "bpmn",
            "subScopeId": null,
            "scopeDefinitionId": null,
            "created": "2022-01-20T13:18:58.255Z",
            "configuration": null,
            "tenantId": ""
        }
    ],
    "total": 1,
    "start": 0,
    "sort": "id",
    "order": "asc",
    "size": 1
}

When I try to execute the message received event using this payload I get a 500 error. I am doing a put on http://thud:8081/flowable-rest/service/runtime/executions/868528bc-79f3-11ec-99f8-0242c0a87006

{
  "action": "messageEventReceived",
  "signalName": "EventKey",
  "messageName": "EventName"
}
{"message":"Internal server error","exception":"Execution with id '868528bc-79f3-11ec-99f8-0242c0a87006' does not have a subscription to a message event with name 'EventName'"}

And when I try to invoke it with a blank or a null messageName, I get this

{"message":"Internal server error","exception":"Execution with id '868528bc-79f3-11ec-99f8-0242c0a87006' does not have a subscription to a message event with name ''"}

Can anyone help me figure out what I’m doing wrong?

You’re trying to mix a message event and an event registry event. Which one are you trying to model? From the XML, it looks like an event registry event? If so - the endpoint should be /event-registry-runtime/event-instances.

Thank you for your response. I am trying to do a message event. I have updated my process as follows:

  <message id="testMessage" name="testMessage"></message>
  <process id="test" name="test" isExecutable="true">
    <startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
    <endEvent id="sid-C07823C5-5245-4ADB-9B9A-B600A7EE56A5"></endEvent>
    <receiveTask id="WaitForMessage" name="WaitForMessage" messageRef="testMessage"></receiveTask>
    <sequenceFlow id="sid-F3B5AABA-36C4-4405-B428-3308A26E0F29" sourceRef="startEvent1" targetRef="WaitForMessage"></sequenceFlow>
    <sequenceFlow id="sid-827E7691-48AD-486D-B630-32271C22051C" sourceRef="WaitForMessage" targetRef="sid-C07823C5-5245-4ADB-9B9A-B600A7EE56A5"></sequenceFlow>
  </process>

But I am still receiving an error when trying to “receive” the event: Execution with id ‘823e1e76-7de3-11ec-893e-0242c0a87005’ does not have a subscription to a message event with name ‘testMessage’

The execution query is also not returning anything for that particular message.

POST /flowable-rest/service/query/executions HTTP/1.1
Content-Type: application/json
{
"messageEventSubscriptionName": "testMessage"
}
HTTP/1.1 200 OK
{"data":[],"total":0,"start":0,"sort":"processInstanceId","order":"asc","size":0}

Hi @bobcat1506

I don’t think the receiveTask has a messageRef property.

To query the runtime executions in your example use:

POST /flowable-rest/service/query/executions HTTP/1.1
Content-Type: application/json
{
"activityId": "WaitForMessage"
}

The “messageEventSubscriptionName” can only be used if you use a message event:

<message id="myMessage" name="messageName" />
<startEvent id="catchMessage">
        <messageEventDefinition messageRef="myMessage" />
 </startEvent>

Regards,
Simon

Thanks for the reply. I found the messageRef in the BPMN spec on page 160 and was trying to make it work. Obviously Flowable may not have implemented this.

For anyone else encountering this issue, I was not able to get the receive task to work with a messageRef. Instead I was able to use an intermediateCatchEvent to accomplish the same thing. Thank you for your help!