# IRPCApplicationTaskQueue.ReserveTasksForProcessing

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Server integration API](https://developer.m-files.com/APIs/gRPC-API/integration/index.md) > [Application task queue](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCApplicationTaskQueue/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCApplicationTaskQueue/ReserveTasksForProcessing/

Badges: `Server integration API / specialized` `write` `session`

Reserves the next waiting task from each of the given queues for the caller to process.

- **Service:** [Application task queue](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCApplicationTaskQueue/index.md) `MFiles.IRPCApplicationTaskQueue`
- **gRPC method:** `/MFiles.IRPCApplicationTaskQueue/ReserveTasksForProcessing`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/reserve-tasks-for-processing`
- **Request:** [`ReserveTasksForProcessingRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCApplicationTaskQueue/ReserveTasksForProcessing/index.md#request)
- **Response:** [`ReserveTasksForProcessingResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCApplicationTaskQueue/ReserveTasksForProcessing/index.md#response)
- **Book and level:** Server integration API, specialized
- **Kind:** write
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** no
- **Returns metadata structure version:** no
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

- Returns at most one task per queue, already in state `APPLICATION_TASK_STATE_IN_PROGRESS`;
  queues with nothing to do contribute nothing. Call it again to get more tasks.
- From a sequential queue, no task is returned while another task of that queue is in progress.
- Tasks added with [AddScheduledTask](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCApplicationTaskQueue/AddScheduledTask/index.md)
  are not returned before their activation time.
- Every queue must be open ("The task queue is not open." otherwise), and the same queue ID must
  not appear twice. Requires a vault session and the vault right `change_full_control_role`.

<a id="request"></a>

## Request: ReserveTasksForProcessingRequest

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `queue_id_collection[]` | repeated `string` | The IDs of the queues to take tasks from. |

<a id="response"></a>

## Response: ReserveTasksForProcessingResponse

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `task_info_collection[]` | repeated [`ApplicationTaskInfo`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ApplicationTaskInfo/index.md) | The reserved tasks, at most one per queue. |
| `task_info_collection[].queue_id` | `string` | ID of the task queue this task belongs to. |
| `task_info_collection[].task_id` | `string` | ID of this task. |
| `task_info_collection[].state` | [`ApplicationTaskState`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.ApplicationTaskState/index.md) | Current state of this task. Values: `APPLICATION_TASK_STATE_WAITING` (0), `APPLICATION_TASK_STATE_IN_PROGRESS` (1), `APPLICATION_TASK_STATE_COMPLETED` (2), `APPLICATION_TASK_STATE_FAILED` (3), `APPLICATION_TASK_STATE_CANCELED` (4), `APPLICATION_TASK_STATE_NONE` (5). |
| `task_info_collection[].progress` | `string` | Current task specific progress amount. |
| `task_info_collection[].task_type` | `string` | Defines the task type. |
| `task_info_collection[].task_data` | `bytes` | Any type specific task payload data. |
| `task_info_collection[].activation_timestamp` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | The earliest time this task can be reserved for processing. |
| `task_info_collection[].latest_activity_timestamp` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | The last modified timestamp. |

<a id="related"></a>

## Related methods

- [AddScheduledTask](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCApplicationTaskQueue/AddScheduledTask/index.md): Adds a task to a task queue that becomes available for processing at a given time.
