# Receive Task and REST API

**URL:** <https://forum.flowable.org/t/receive-task-and-rest-api/8901>\
**Category:** Flowable Engine\
**Created:** [January 20, 2022, 2:11pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901 "2022-01-20T14:11:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobcat1506](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bobcat1506](https://forum.flowable.org/u/bobcat1506)\
**Post date:** [January 20, 2022, 2:11pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/1 "2022-01-20T14:11:25Z")

</div>

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:

```xml
<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.

```json
{
    "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](http://thud:8081/flowable-rest/service/runtime/executions/868528bc-79f3-11ec-99f8-0242c0a87006)

```json
{
  "action": "messageEventReceived",
  "signalName": "EventKey",
  "messageName": "EventName"
}

```

```json
{"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

```json
{"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?

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [January 24, 2022, 3:25pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/2 "2022-01-24T15:25:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bobcat1506](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bobcat1506](https://forum.flowable.org/u/bobcat1506)\
**Post date:** [January 25, 2022, 1:38pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/3 "2022-01-25T13:38:43Z")

</div>

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

```xml
  <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’

---

<div class="post-metadata">

**Author:** ![bobcat1506](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bobcat1506](https://forum.flowable.org/u/bobcat1506)\
**Post date:** [January 25, 2022, 3:03pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/4 "2022-01-25T15:03:00Z")

</div>

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

```auto
POST /flowable-rest/service/query/executions HTTP/1.1
Content-Type: application/json
{
"messageEventSubscriptionName": "testMessage"
}

```

```auto
HTTP/1.1 200 OK
{"data":[],"total":0,"start":0,"sort":"processInstanceId","order":"asc","size":0}

```

---

<div class="post-metadata">

**Author:** ![amporsim](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@amporsim](https://forum.flowable.org/u/amporsim)\
**Post date:** [January 25, 2022, 3:53pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/5 "2022-01-25T15:53:20Z")

</div>

Hi @bobcat1506

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

To query the runtime executions in your example use:

```auto
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:

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

```

Regards,  
Simon

---

<div class="post-metadata">

**Author:** ![bobcat1506](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bobcat1506](https://forum.flowable.org/u/bobcat1506)\
**Post date:** [January 26, 2022, 5:58pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/6 "2022-01-26T17:58:30Z")

</div>

Thanks for the reply. I found the messageRef in the [BPMN](https://www.omg.org/spec/BPMN/2.0.2/PDF) spec on page 160 and was trying to make it work. Obviously Flowable may not have implemented this.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/a/a760527668205b671e73117667bc746a9d412201.png)

---

<div class="post-metadata">

**Author:** ![bobcat1506](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bobcat1506](https://forum.flowable.org/u/bobcat1506)\
**Post date:** [January 26, 2022, 9:42pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/7 "2022-01-26T21:42:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![wberges](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wberges/32/940_2.png) [@wberges](https://forum.flowable.org/u/wberges)\
**Post date:** [August 22, 2023, 4:43pm UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/8 "2023-08-22T16:43:09Z")

</div>

Thanks for this info @bobcat1506  
It’s really strange to have a Receive Task which is not waiting for a message/signal event…  
It should be the same triggering as an intermediate catch event, with possibility to add some code inside and also map boundary events.  
For example:  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/4/49e4507f44c666b8a0f93ff33b32d41a5ff955cc.png)  
must be replaced by such workaround (or equivalent):  
 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/f/f56caeaa4546c480ec554b6313a08776268f544f.png)  
It’s a pity ☹

---

<div class="post-metadata">

**Author:** ![wberges](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/wberges/32/940_2.png) [@wberges](https://forum.flowable.org/u/wberges)\
**Post date:** [August 23, 2023, 8:28am UTC](https://forum.flowable.org/t/receive-task-and-rest-api/8901/9 "2023-08-23T08:28:12Z")

</div>

After more investigations, it seems that it is possible to trigger a Receive event using a signal (not a message):

```auto
PUT http://localhost:8080/flowable-ui/process-api/runtime/executions/0753121c-418e-11ee-9cda-747827997e23
{
    "action":"signal"
 }

```

BUT I haven’t found a way to target a specific signal (e.g. using _“signalName” : “MySignalName”_)  
meaning that, if I have several receive tasks grouped in the same branch (same execution so), a retry with the same call will trigger the next receive tasks…  
And [the documentation](https://www.flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs#java-receive-task) about this receive task doesn’t help a lot for this part. ☹
