Postgres Job Queue With Retries And Dead Letter Table

    What this workflow does

    The workflow contains these steps: Every Minute → Run Once to Create Tables → Queue Settings → Check Settings → Settings Valid? → Stop: Invalid Settings → Create Tables Run? → Create Queue Tables → Release Stuck Jobs → Claim Job Batch → Job Claimed? → Do the Work → Mark Job Done → Schedule Retry or Dead-Letter → Find Unreported Dead Letters → Build Digest Email → Email Dead Letter Digest → Mark Dead Letters Reported → Stop: Digest Email Failed.

    What you need

    • An n8n instance to import and run the workflow.
    • StickyNote access for the StickyNote steps listed in this workflow.
    • Schedule access for the Schedule steps listed in this workflow.
    • ManualTrigger access for the ManualTrigger steps listed in this workflow.
    • Set access for the Set steps listed in this workflow.
    • Code access for the Code steps listed in this workflow.
    • IF access for the IF steps listed in this workflow.
    • StopAndError access for the StopAndError steps listed in this workflow.
    • Postgres access for the Postgres steps listed in this workflow.
    • HTTP Request access for the HTTP Request steps listed in this workflow.
    • EmailSend access for the EmailSend steps listed in this workflow.

    Workflow nodes

    1. Every Minute (n8n-nodes-base.scheduleTrigger)
    2. Run Once to Create Tables (n8n-nodes-base.manualTrigger)
    3. Queue Settings (n8n-nodes-base.set)
    4. Check Settings (n8n-nodes-base.code)
    5. Settings Valid? (n8n-nodes-base.if)
    6. Stop: Invalid Settings (n8n-nodes-base.stopAndError)
    7. Create Tables Run? (n8n-nodes-base.if)
    8. Create Queue Tables (n8n-nodes-base.postgres)
    9. Release Stuck Jobs (n8n-nodes-base.postgres)
    10. Claim Job Batch (n8n-nodes-base.postgres)
    11. Job Claimed? (n8n-nodes-base.if)
    12. Do the Work (n8n-nodes-base.httpRequest)
    13. Mark Job Done (n8n-nodes-base.postgres)
    14. Schedule Retry or Dead-Letter (n8n-nodes-base.postgres)
    15. Find Unreported Dead Letters (n8n-nodes-base.postgres)
    16. Build Digest Email (n8n-nodes-base.code)
    17. Email Dead Letter Digest (n8n-nodes-base.emailSend)
    18. Mark Dead Letters Reported (n8n-nodes-base.postgres)
    19. Stop: Digest Email Failed (n8n-nodes-base.stopAndError)
    StickyNoteScheduleManualTriggerSetCodeIFStopAndErrorPostgresHTTP RequestEmailSend
    24 nodesData Processing
    View on GitHub

    Need this workflow customized or debugged? Book a 30-min scope call →

    Want this set up for you? Book a 30-min scope call

    I build and fix n8n workflows for agencies and SaaS teams. 30-minute scope call — bring the problem, leave with an estimate.

    Related workflows