JVM - queue()
Creates a new Queue to send and receive asynchronous tasks.
import io.nitric.Nitric;import io.nitric.resources.QueuePermission;public class Application {public static void main(String[] args) {var queue = Nitric.INSTANCE.queue("batch").with(QueuePermission.Send);Nitric.INSTANCE.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 code needs to the resource. See here for details about infrastructure security.
Available permissions:
QueuePermission.Send
This permission allows your code to send new tasks to the queue.
QueuePermission.Receive
This permission allows your code to receive tasks from the queue.
In most instances, code should either send to or receive from a queue, usually not both.
Examples
Create a Queue
import io.nitric.Nitric;import io.nitric.resources.QueuePermission;public class Application {public static void main(String[] args) {var queue = Nitric.INSTANCE.queue("batch").with(QueuePermission.Send);Nitric.INSTANCE.run();}}
Receive tasks from a queue
import io.nitric.Nitric;import io.nitric.resources.QueuePermission;public class Application {public static void main(String[] args) {var queue = Nitric.INSTANCE.queue("batch").with(QueuePermission.Receive);var tasks = queue.receive(10);Nitric.INSTANCE.run();}}
Last updated on Oct 11, 2024