Application task queue (IRPCApplicationTaskQueue)
Persistent task queues and broadcast messages that vault applications use to share background work between the server instances of a vault.
This interface provides access to vault specific task queue for adding and managing the tasks.
| gRPC service | MFiles.IRPCApplicationTaskQueue |
|---|---|
| Book and level | Server integration API, specialized |
| Methods | 12 |
| Proto file | mfiles/IRPCApplicationTaskQueue.proto |
Overview
This is the server side of the task queue API that vault applications use through the M-Files
API (Vault.ApplicationTaskOperations). A vault application opens named queues, adds tasks
with an opaque payload, and its instances on every server of the vault reserve, process and
update them. Queues also carry broadcast messages that every consumer reads.
Who should call it. Vault applications, through the M-Files API. An external application normally should not: the queues belong to the vault applications that open them, and reserving or updating their tasks takes work away from those applications. Use it only for queues that your own code owns, or read-only for diagnostics (GetTaskQueues, GetTaskIdentifiersFromQueue, GetApplicationTasks).
Rights. Every method needs a vault session of a user with an account in the vault and the
vault right change_full_control_role, which only users with full control of the vault have; a
normal user gets "Access denied.". The vault's internal queues, such as
m-files.server.core.broadcast, are refused with "Access denied." by the methods that open,
add to, reserve from, broadcast to or destroy a queue, but they are listed by
GetTaskQueues.
Task life cycle (ApplicationTaskState):
- OpenTaskQueue creates the queue if it does not exist. Call it before adding or reserving.
- AddTask or
AddScheduledTask adds a task in
state
APPLICATION_TASK_STATE_WAITING. - ReserveTasksForProcessing
moves a waiting task to
APPLICATION_TASK_STATE_IN_PROGRESSand returns it to one caller. - UpdateTask reports progress and finally
sets
COMPLETED,FAILEDorCANCELED. An in-progress task that is not updated within its restore timeout goes back to waiting and can be reserved again.
The server cleans up by itself: completed tasks are deleted; failed and cancelled tasks and broadcast messages after a day; and queues that have not been used for seven days, together with their tasks.
Methods
| Method | Summary | Facts |
|---|---|---|
| AddScheduledTask | Adds a task to a task queue that becomes available for processing at a given time. | write session |
| AddTask | Adds a task to a task queue, ready to be reserved at once. | write session |
| ClearAndDestroyTaskQueue | Deletes a task queue and all of its tasks. | write session |
| GetApplicationTasks | Gets tasks by ID without reserving them. | write session |
| GetLatestBroadcastMessageIdentifiers | Gets the ID of the newest broadcast message of each given queue. | write session |
| GetNewBroadcastMessages | Gets the broadcast messages of a queue that are newer than the given message ID. | write session |
| GetTaskIdentifiersFromQueue | Gets the IDs of the tasks of a queue that are in the given states. | write session |
| GetTaskQueues | Gets the IDs of all task queues of the vault. | write session |
| OpenTaskQueue | Creates a task queue if it does not exist, or confirms an existing one. | write session |
| ReserveTasksForProcessing | Reserves the next waiting task from each of the given queues for the caller to process. | write session |
| SendBroadcastMessage | Sends a broadcast message through a task queue to every consumer of that queue. | write session |
| UpdateTask | Reports the progress or the final state of a task. | write session |