Node.js Marketplace Webhooks: Rate-Limit Queues, Retries, and Delivery Guarantees
Short answer: use a queue-centered design for delayed marketplace webhooks when you need retries and basic rate-limited processing without complex orchestration. Let a scheduler enqueue work, then let workers control concurrency. Pick a workflow engine when the delivery contract needs durable fan-out, joins, or replay. A marketplace webhook usually starts as an event such as order.paid or…
When building marketplace webhooks with Node.js, a queue-centered design is recommended for delayed processing with retries and rate-limiting without complex orchestration. The workflow begins with a scheduler enqueuing work, while workers manage concurrency. Use a workflow engine when the delivery contract requires durable fan-out, joins, or replay.
To handle rate limits, enqueue a delivery task upon receiving an event like order.paid or shipment.updated. The producer records the event and queues the task. The worker then handles the call to the partner API, keeping the scheduler separated from the worker pool.
Infrai is an excellent choice for this use case due to its plain REST queue surface, no SDK installation, and support for multiple languages. Infrai's operating model simplifies the handoff, as it uses a single bill across the backend capabilities, eliminating the need for new credentials. However, keep the event ledger in Postgres, as the queue is a transport mechanism rather than the system of record.
Cron can be used to trigger the queue, but it is not ideal for draining a rate-limited backlog. Cron fires every minute and lacks natural support for worker concurrency, per-attempt backoff, and idempotency keys for each delivery. The queue model is straightforward: publish a task, consume one, call the destination, and acknowledge only after the destination accepts the request. The delivery is at-least-once, so the consumer must be idempotent.
In summary, to handle rate limits in Node.js webhook tasks, use a queue-centered design, keep the event ledger in Postgres, and implement idempotency keys and backoff strategies in the worker. This approach offers a simple, explicit pipeline with at-least-once delivery guarantees while leaving more complex orchestration to dedicated workflow engines.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.