Queues and topics¶
Durable message queues for work that should not be lost when a service restarts, and topics that fan one message out to several queues.
| Object | What it is |
|---|---|
| Queue | Holds messages until a consumer takes them. |
| Topic | A place to publish to. It keeps nothing itself: each message goes to every subscription whose filter matches. |
| Subscription | Connects a topic to a queue (or to a webhook), with an optional filter on the routing key. |
| Credential | A user name and password for AMQP clients running inside the platform. |
Create¶
Queues in the console has three tabs: Queues, Topics and Credentials. A queue or a topic needs
only a name: 1 to 50 characters, lowercase letters, digits and single dashes. Names starting with
rso- are reserved for the platform.
A subscription names a topic, a target queue and optionally a filter. Routing keys are words
separated by dots; in a filter * stands for exactly one word and # for any number of words, so
order.* matches order.created and not order.created.eu. Without a filter a subscription
receives everything.
Publish and receive over HTTP¶
The HTTP API works from anywhere with an access token (your session or a
service account). The Connect card on the Queues page shows
the endpoint and ready-made curl commands for your tenant.
# Publish to a queue
curl -X POST https://gateway.cloud.rso.dev/queues/v1/queues/orders/messages \
-H "Authorization: Bearer $RSO_DEV_ACCESS_TOKEN" \
-H "X-Tenant: <tenant-id>" \
-H "Content-Type: application/json" \
-d '{"json": {"orderId": 7}, "attributes": {"source": "checkout"}}'
# Publish to a topic with a routing key
curl -X POST https://gateway.cloud.rso.dev/queues/v1/topics/events/messages \
-H "Authorization: Bearer $RSO_DEV_ACCESS_TOKEN" \
-H "X-Tenant: <tenant-id>" \
-H "Content-Type: application/json" \
-d '{"json": {"orderId": 7}, "routingKey": "order.created"}'
# Receive up to 10 messages from a queue
curl -X POST https://gateway.cloud.rso.dev/queues/v1/queues/orders/receive \
-H "Authorization: Bearer $RSO_DEV_ACCESS_TOKEN" \
-H "X-Tenant: <tenant-id>" \
-H "Content-Type: application/json" \
-d '{"max": 10}'
| Request field | Meaning |
|---|---|
body or json |
The message: a string, or a JSON value that is serialised for you. |
contentType |
Optional; defaults to application/json when json is used. |
attributes |
Optional string key-value pairs delivered with the message. |
messageId |
Optional id of your own, delivered with the message. |
routingKey |
Topics only. |
A publish answers {"routed": true}. Publishing to a topic that has no matching subscription
succeeds with routed: false, and the message is gone. A receive answers {"messages": [...]},
each with body, contentType, attributes, messageId, publishedAt, topic, routingKey
and redelivered; max is 1 to 32 and defaults to 1.
Delivery guarantees¶
- Publishing returns after the message is stored durably.
- Receiving over HTTP removes the messages as they are handed out (at-most-once). If your process fails after the response, those messages are lost. Use it for work that can tolerate that, or for inspection.
- AMQP consumers acknowledge each message (at-least-once): a message that was not acknowledged is delivered again.
- Webhooks push messages to an HTTPS endpoint, at-least-once, with retries.
- Messages in a queue keep their order. A message can be delivered more than once on the at-least-once paths, so make handlers idempotent.
AMQP¶
Credentials → Create issues a user name and password for AMQP 0-9-1 clients; the password and the connection URI are shown once. The host, port and virtual host are on the Connect card.
- Credentials work from inside the platform only (apps, scheduled jobs and other workloads in your tenant). They are not reachable from the internet or from instances yet.
- A credential can publish and consume. It cannot declare queues or exchanges: create them in the console or the API, and configure clients that declare on start-up to use passive declarations.
- A credential reaches every queue and topic of the tenant.
Limits¶
| Limit | Value |
|---|---|
| Queues per tenant | queues quota, default 20 |
| Topics per tenant | topics quota, default 20 |
| Message size | 256 KiB |
| Messages kept per queue | 100,000 or 64 MiB, whichever comes first; beyond that the oldest are dropped |
| Retention | a message nobody takes is dropped after 7 days |
| Messages per receive | 32 |
| HTTP API rate | 600 requests a minute per client address |
Permissions¶
Viewers can see queues and topics. Creating, deleting and purging them, managing subscriptions and credentials, publishing and consuming are separate permissions that editors hold by default. Each can be granted for some queues or topics only.
Deleting a queue or a topic also deletes the webhooks and scheduled messages built on it. Queues are not metered at the moment.