# How does delayed Queueable job execution work and what are its primary use cases?

**Topic:** Apex · **Difficulty:** Medium · **Tags:** Apex, Asynchronous Apex, Queueable Apex

Read it on the site: https://www.forcechallenges.com/interview-questions/how-does-delayed-queueable-job-execution-work-and-what-are-its-primary-use-cases

## Answer

**Basics:** Previously, queueable jobs started as soon as resources were free. With the delay overload you tell the platform not to start the job before a minimum number of minutes has passed.

**How it works:** Call `System.enqueueJob(new MyJob(), 5);` and the job is queued with a minimum wait of 5 minutes. It returns the job Id like a normal enqueue. For more control use AsyncOptions: set MinimumQueueableDelayInMinutes, MaximumQueueableStackDepth and a DuplicateSignature (built with QueueableDuplicateSignature.Builder) to prevent duplicate jobs. Admins may also have an org-level default delay setting in Apex Settings; verify in current release notes.

**Advanced / deep dive:** Use cases: retry with backoff after a failed callout, spacing calls to a rate-limited API, letting a record lock or an external process finish, or batching bursts of triggers into a single later job via duplicate signatures. Combine with Finalizers: attach System.attachFinalizer to detect failure and re-enqueue with a longer delay. The delay is a minimum, not a guarantee of exact start time. A delayed job still counts toward the 50-jobs-per-transaction limit. Compare: Scheduled Apex has a heavier setup and minute granularity at best, while Platform Events or Flow Scheduled paths are alternatives for declarative designs.

**Code / config example:**
```apex
public class RetryJob implements Queueable, Database.AllowsCallouts {
    private Integer attempt;
    public RetryJob(Integer attempt) { this.attempt = attempt; }
    public void execute(QueueableContext ctx) {
        // callout here; on failure retry with growing delay
        if (attempt < 3) {
            System.enqueueJob(new RetryJob(attempt + 1), 2 * attempt);
        }
    }
}
```

**Hidden gotchas & must-remember points:**
- Valid delay range is 0 to 10 minutes.
- Callouts from Queueable require Database.AllowsCallouts.
- Delay is a minimum; do not rely on precise timing.
- Chaining still allows only one child per running job.
- Delay does not bypass daily async limits.

**Best practice:** Use delayed enqueue with a retry counter and a cap, and log permanent failures.

---
Source: ForceChallenges · last updated 2026-11-02
