Node.js - queue()
Creates a new Queue to process asynchronous messages.
import { queue } from '@nitric/sdk'const batchQueue = queue('batch').allow('enqueue')
Parameters
- Name
name
- Required
- Required
- Type
- string
- Description
The unique name of this Queue within the service. Subsequent calls to
queue
with the same name will return the same object.
Access
All Nitric resources provide access permissions you can use to specify the level of access your service needs to the resource. See here for details about infrastructure security.
Available permissions:
enqueue
This permission allows your service to enqueue new messages.
dequeue
This permission allows your service to dequeue messages and complete them.
Notes
In most instances, code should either enqueue or dequeue from a queue, usually not both.
Examples
Create a Queue
import { queue } from '@nitric/sdk'const batchQueue = queue('batch')
Enqueue messages
import { queue } from '@nitric/sdk'const payload = {}const batchQueue = queue('batch').allow('dequeue')const messages = await batchQueue.enqueue()
Last updated on Oct 22, 2024