Task Queues
The Outbox Pattern is a reliable strategy used in distributed systems to ensure that messages or events are consistently recorded and delivered, even in the face of failures. This pattern, however, can not only be applied to outbound messages, but to inbound messages and server-internal background tasks as well. The core principle remains the same:
- Persist the message (or task) in the database -- using the same transaction as the triggering action, if applicable
- Process it asynchronously afterwards -- incl. retries, if necessary
Over the next months, CAP will evolve its outbox to generic Task Queues with the following four components:
- Outbox → for outbound calls to remote services
- Inbox → for asynchronously handling inbound requests
- Background tasks → e.g., scheduled periodically
- Callbacks → implement SAGA patterns
This guide will grow with the functionality.
Outbox
Regarding the outbox, please see the following existing documentation:
- Transactional Outbox in CAP Java
- Outboxing with
cds.queued
in CAP Node.js
Inbox beta
Through the inbox, inbound messages can be accepted as asynchronous tasks. That is, the messaging service persists the message to the database, acknowledges it to the message broker, and schedules its processing.
Simply configure your messaging service for Node.js as cds.requires.messaging.inboxed = true
and for CAP Java as cds.messaging.services
Inboxing moves the dead letter queue into your CAP app❗️
With the inbox, all messages are acknowledged towards the message broker regardless of whether they can be processed or not. Hence, failures need to be managed via the dead letter queue built on cds.outbox.Messages
.
Learn more about the dead letter queue in Node.js.Learn more about the dead letter queue in Java.
Inboxing is especially beneficial in case the message broker does not allow to trigger redelivery and/ or "fix" the message payload.
More to Come
This documentation is not complete yet, or the APIs are not released for general availability. Stay tuned to upcoming releases for further updates.