Messaging - Queues

1. System Context

Developers use Nitric to define required message queues within their application.

  • App code uses the Queue resource from the Nitric SDK.
  • Developers define queues their application requires and implement application logic to send or receive messages.

Operations use default or overridden IaC (e.g Terraform modules) to provision the necessary resources for their target cloud.

Example AWS Provider
  • AWS SQS serves as the message queuing service.
  • AWS IAM provides roles and policies for secure access to SQS queues.
Code
Terraform
Create SQS Queue
Access SQS Queue
Provide Access
Developer
Operations
nitric up
AWS SQS Queue
AWS Lambda Functions
AWS IAM
Example GCP Provider
  • Google Pub/Sub Topic serves as the message queuing service.
  • Google Pub/Sub Subscription emulates a queue by creating a pull subscription for the topic.
Code
Terraform
Create Pub/Sub Topic
Pull Messages
Developer
Operations
nitric up
Google Pub/Sub Topic
Google Pub/Sub Subscription

2. Sequence

Build Sequence

Below is a sequence diagram showing the sequence of events when a developer registers a Queue with Nitric. This is the process that occurs when using the nitric up command.

App Worker(s)Nitric SDKNitric CLINitric ProviderIaCRegister QueueRegister Access RequirementsRegister QueueRegister Access RequirementsForward Nitric SpecProvision QueueProvision IAMApp Worker(s)Nitric SDKNitric CLINitric ProviderIaC

Runtime Sequence

Below is the runtime flow when performing operations on a Queue using Nitric, such as enqueueing or dequeueing messages. The example shows an Enqueue operation, which sends a message to the queue.

App CodeNitric SDKNitric Runtime (plugin)Document DB (e.g. AWS SQS)Enqueue(message)Forward RequestConvert RequestQueue API RequestApp CodeNitric SDKNitric Runtime (plugin)Document DB (e.g. AWS SQS)

3. Component

Queue Module

  • Ensures the deployment of a scalable, provider-agnostic message queue with a consistent naming convention for seamless integration.
  • Configures metadata or tags for resource identification, governance, and management.
  • Implements secure access by dynamically assigning permissions to applications or services, enforcing the principle of least privilege.
  • Supports configurable event-driven workflows, enabling the integration of producer-consumer patterns and worker pipelines.
  • Provides dynamic configurations to handle varying workloads and queue-specific parameters such as message retention, delivery delay, and dead-letter queues.
  • Abstracts the underlying queuing infrastructure, allowing developers and operations teams to focus on messaging logic rather than provider-specific APIs.

4. Code

Developers write application code that uses the Queue resource from the SDK, configures the secret, and implements the application logic to access and manage secrets.

SDK Reference by language -

Operations will use or extend the Nitric infrastructure modules, including both Terraform and Pulumi:

Last updated on Feb 15, 2025