Topics

One message delivered to every subscription: queues and signed webhooks.

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

Topics architectureOne publish, one copy per subscription.APIpublishes orderTopic ordersQueue emailsQueue stockWebhooksigned
One publish, one copy per subscription.
  • API to Topic orders
  • Topic orders to Queue emails
  • Topic orders to Queue stock
  • Topic orders to Webhook

Flows

An order is placed

  1. The API publishes once.
  2. Each subscription gets its own copy.
  3. Each worker acts on its copy independently.

Set it up

In the console

  1. Open Topics and choose New topic.
  2. Add queues or webhook addresses.
  3. Publish from the Deliveries tab to try it.

With the CLI

enclave topic create orders --queue emails --wait

With 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.

enclave_topic
NameTypeUseWhat it does
nametextrequiredName of the topic: 3–40 lowercase letters, digits or hyphens, starting with a letter. Changing it replaces the topic.
projecttextoptionalThe project to create it in. Defaults to the provider's project (ENCLAVE_PROJECT, else default). Changing it replaces the resource.
retention_hoursnumberoptionalHow long published messages are kept for retries, 1–336 (default 24).
subscriptionslist of objectsoptionalUp to 20 subscriptions: exactly one of queue or url each.
broker_urltextoutputThe broker on this machine, nats://127.0.0.1:<port>.
idtextoutputResource ID.
internal_broker_urltextoutputThe broker inside EnclaveStack's networks, nats://es-system-broker:4222.
password_secrettextoutputName of the managed secret holding the user's password.
subjecttextoutputThe subject apps publish to.
usernametextoutputThe 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.