Background Jobs and Webhooks

Module:Core concept

Slow work such as email, exports, and provider events should be durable asynchronous work when it need not block a request.

How to apply it

Use stable job/event IDs, tenant context, bounded retries with exponential backoff and jitter, and a failed-job workflow. Verify webhook signatures against the raw body, persist unique event IDs, acknowledge after durable acceptance, and process idempotently.

Worked example

A unique provider event ID prevents a retried payment webhook from applying the same transition twice; reconciliation repairs missed events.

Common mistakes to avoid

Assuming webhook delivery is ordered or that a timeout proves an operation did not happen.

Practice task

Implement this concept in the capstone. Add one positive test, one negative or failure-path test, and a short note explaining the trade-off you chose.

Key Takeaways
  • Slow work such as email, exports, and provider events should be durable asynchronous work when it need not block a request.
  • Use stable job/event IDs, tenant context, bounded retries with exponential backoff and jitter, and a failed-job workflow.
Knowledge Check

What is the strongest production practice for Background Jobs and Webhooks?