Course contentsShow
← Cloud and Infrastructure
Lesson 2723 of 2,98959. Queueing and Async PatternsFree lesson

Delay Queues and Message Timers

Deferring message delivery with delay queues and per-message timers for scheduled processing.

Delay Queues and Message Timers

What you'll learn: How to defer message delivery using delay queues and per-message timers for scheduled processing.

Sometimes you don't want a message processed immediately—you need it handled later. Delay queues and message timers let you schedule when messages become visible to consumers, enabling time-based workflows without external schedulers.

What Are Delay Queues?

A delay queue applies a default delay period to all messages sent to that queue. When you send a message, it enters the queue but remains invisible to consumers for the configured delay duration (e.g., 5 minutes). After the delay expires, the message becomes available for processing.

Think of it like a timed safe: you deposit something now, but it locks for a set period before anyone can access it.

Per-Message Timers

Message timers provide finer control—you set the delay on individual messages rather than the entire queue. This allows mixed-urgency messages in the same queue: some process immediately (0 delay), others after 10 seconds, and some after an hour.

This is like putting different items in timed lockers with individual countdown timers rather than one global release time.

Common Use Cases

  • Scheduled reminders: Send a notification 24 hours after user signup
  • Retry with backoff: Requeue failed tasks with increasing delays
  • Rate limiting: Space out API calls to external services
  • Workflow orchestration: Trigger steps after waiting periods (e.g., "cancel order if unpaid after 15 minutes")
  • Business logic delays: Process refunds after return window closes

Implementation Notes

Maximum delays vary by platform (AWS SQS supports up to 15 minutes for delay queues, individual messages up to 15 minutes). For longer delays, combine with Dead Letter Queues or external scheduling services.

Key Takeaway: Delay queues and message timers enable time-based asynchronous workflows by controlling when messages become visible to consumers, eliminating the need for external scheduling infrastructure for common deferral patterns.