> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aseeflow.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Receive Task

A Receive Task is a simple task that waits for the arrival of a certain message. When the process execution arrives at a Receive Task, the process state is committed to the persistence storage. This means that the process will stay in this wait state until a specific message is received by the engine, which triggers continuation of the process beyond the Receive Task.

![](https://mintcdn.com/aseeflow/OpLRJy6TPnBLn55c/img/short-codes/bpmn-receive-task.png?fit=max\&auto=format\&n=OpLRJy6TPnBLn55c\&q=85\&s=50f45dc643e6b2488ae02ad50c95440f)

A Receive Task with a message reference can be triggered like an ordinary event:

```xml theme={null}
<definitions ...>
  <message id="newInvoice" name="newInvoiceMessage"/>
  <process ...>
    <receiveTask id="waitState" name="wait" messageRef="newInvoice">
  ...
```

You can then either correlate the message:

```java theme={null}
// correlate the message
runtimeService.createMessageCorrelation(subscription.getEventName())
  .processInstanceBusinessKey("AB-123")
  .correlate();
```

Or explicitly query for the subscription and trigger it:

```java theme={null}
ProcessInstance pi = runtimeService.startProcessInstanceByKey("processWaitingInReceiveTask");

EventSubscription subscription = runtimeService.createEventSubscriptionQuery()
  .processInstanceId(pi.getId()).eventType("message").singleResult();

runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId());
```

> [!WARNING]
>
> Correlation of a parallel multi instance isn't possible because the subscription can't be identified unambiguously.

To continue a process instance that is currently waiting at a Receive Task without a message reference, the `runtimeService.signal(executionId)` can be called, using the id of the execution that arrived in the Receive Task.

```xml theme={null}
<receiveTask id="waitState" name="wait" />
```

The following code snippet shows how this works in practice:

```java theme={null}
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
Execution execution = runtimeService.createExecutionQuery()
  .processInstanceId(pi.getId()).activityId("waitState").singleResult();

runtimeService.signal(execution.getId());
```

## ASEE Flow Extensions

<table>
  <tr> <th>Attributes</th> <td> [camunda:asyncBefore](https://docs.aseeflow.org/1.x/reference/bpmn20/custom-extensions/extension-attributes.md#asyncbefore), [camunda:asyncAfter](https://docs.aseeflow.org/1.x/reference/bpmn20/custom-extensions/extension-attributes.md#asyncafter), [camunda:exclusive](https://docs.aseeflow.org/1.x/reference/bpmn20/custom-extensions/extension-attributes.md#exclusive), [camunda:jobPriority](https://docs.aseeflow.org/1.x/reference/bpmn20/custom-extensions/extension-attributes.md#jobpriority) </td> </tr>
  <tr> <th>Extension Elements</th> <td> [camunda:failedJobRetryTimeCycle](https://docs.aseeflow.org/1.x/reference/bpmn20/custom-extensions/extension-elements.md#failedjobretrytimecycle), [camunda:inputOutput](https://docs.aseeflow.org/1.x/reference/bpmn20/custom-extensions/extension-elements.md#inputoutput) </td> </tr>
  <tr> <th>Constraints</th> <td> The `camunda:exclusive` attribute is only evaluated if the attribute `camunda:asyncBefore` or `camunda:asyncAfter` is set to `true` </td> </tr>
</table>

## Additional Resources

* [Tasks](https://camunda.com/bpmn/reference/#activities-task) in the [BPMN 2.0 Modeling Reference](https://camunda.com/bpmn/reference/)
* [Message Receive Events](https://docs.aseeflow.org/1.x/reference/bpmn20/events/message-events.md)
* [Trigger a subscription via REST](https://docs.aseeflow.org/reference/rest/1.x/execution/trigger-execution.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.