Delayed Message Processing
Delayed message processing is a pattern in which a message is published now but deliberately withheld from consumers until a specified time in the future, enabling scheduled execution of business logic without a separate cron or job scheduling system.
Delayed message processing is a pattern in which a message is published now but deliberately withheld from consumers until a specified time in the future, enabling scheduled execution of business logic without a separate cron or job scheduling system.
Many business workflows require time-delayed execution: send a reminder email 24 hours after a trial signup, cancel an order if payment is not confirmed within 15 minutes, retry a webhook delivery after 5 minutes. Rather than polling a database on a schedule, delayed messaging encodes the execution time into the message itself and lets the broker handle the scheduling.
Implementations vary by platform. AWS SQS supports a delivery delay of up to 15 minutes at the message level, after which the message becomes visible to consumers. For longer delays, the common pattern is a delay queue backed by a persistent store (DynamoDB, Redis Sorted Set with score = fire-at timestamp) from which a scheduler polls and re-enqueues messages to the main queue when their time arrives. RabbitMQ supports per-message TTL combined with dead-letter routing to achieve similar results.
The visibility timeout mechanism used by SQS-style queues is a related concept: when a consumer fetches a message, it becomes invisible to other consumers for a configurable period. If the consumer fails to acknowledge within that window, the message becomes visible again — similar to a short automatic delay for retry purposes. This mechanism powers Message Queue Retry.
For precision scheduling (sub-second granularity) or very long delays (days to weeks), a dedicated scheduler like Temporal, Quartz, or a database-backed job queue is more appropriate than a message broker's native delay features.