Overview
A topic sends each message it gets to every subscription: your queues, and web addresses signed with a secret.
When to use it
- One event, several reactions.
- Telling another service when something happens.
How it works
- NATS JetStream
- The same broker as queues.
- Signed webhooks
- Deliveries can carry an HMAC-SHA256 signature from a secret.
Each published message is kept for the retention period so a subscription that fails can get it again; the Deliveries tab shows what arrived where.
Architecture
- API to Topic orders
- Topic orders to Queue emails
- Topic orders to Queue stock
- Topic orders to Webhook
Flows
An order is placed
- The API publishes once.
- Each subscription gets its own copy.
- Each worker acts on its copy independently.
Set it up
In the console
- Open Topics and choose New topic.
- Add queues or webhook addresses.
- Publish from the Deliveries tab to try it.
With the CLI
enclave topic create orders --queue emails --waitWith OpenTofu
OpenTofu configuration
resource "enclave_topic" "orders" {
name = "orders"
subscriptions = [
{ queue = "emails" },
]
}Settings reference
Every setting and output of the OpenTofu resource; the console and the CLI use the same names in their own words. Generated from platform 4d30582.
| Name | Type | Use | What it does |
|---|---|---|---|
name | text | required | Name of the topic: 3–40 lowercase letters, digits or hyphens, starting with a letter. Changing it replaces the topic. |
project | text | optional | The project to create it in. Defaults to the provider's project (ENCLAVE_PROJECT, else default). Changing it replaces the resource. |
retention_hours | number | optional | How long published messages are kept for retries, 1–336 (default 24). |
subscriptions | list of objects | optional | Up to 20 subscriptions: exactly one of queue or url each. |
broker_url | text | output | The broker on this machine, nats://127.0.0.1:<port>. |
id | text | output | Resource ID. |
internal_broker_url | text | output | The broker inside EnclaveStack's networks, nats://es-system-broker:4222. |
password_secret | text | output | Name of the managed secret holding the user's password. |
subject | text | output | The subject apps publish to. |
username | text | output | The broker user apps sign in as. |
Limits and security
Good to know
- Messages kept 1 – 336 hours (24 by default) for retries.
Security
- Sign webhooks so receivers can check where they came from.