Python - queue()
Creates a new Queue to process asynchronous messages.
from nitric.resources import queuefrom nitric.application import Nitricbatch_queue = queue('batch').allow('enqueue')Nitric.run()
Parameters
- Name
name
- Required
- Required
- Type
- string
- Description
The unique name of this Queue within the app. 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 code to enqueue messages.
dequeue
This permission allows your code to dequeue messages.
Notes
In most instances code should either enqueue or dequeue, usually not both.
Examples
Create a Queue
from nitric.resources import queuefrom nitric.application import Nitricbatch_queue = queue('batch').allow('enqueue')Nitric.run()
Enqueue messages
from nitric.resources import queuefrom nitric.application import Nitricbatch_queue = queue('batch').allow('enqueue')payload = {}await batch_queue.send(payload)Nitric.run()
Dequeue messages
from nitric.resources import queuefrom nitric.application import Nitricpayload = {}batch_queue = queue('batch').allow('dequeue')messages = await batch_queue.dequeue(10)Nitric.run()
Last updated on Nov 11, 2024