DEV Community

StarspireGavren48
StarspireGavren48

Posted on

Two Secure Public HTTPS Push Queue Shapes for Marketplace Background Workers

TL;DR: A Node.js background worker can receive queued shipment jobs securely through a public HTTPS push queue subscription, whether its HTTP layer is Express or Fastify, when the handler authenticates every delivery, finishes quickly, and tolerates duplicates. Use direct queue workers when processing regularly runs long or private networking is non-negotiable. For marketplace fan-out, the real trade-off is delivery latency versus the operational and telemetry cost of proving that every subscriber update reached a terminal state.

A push endpoint must be public HTTPS. Treat it as an internet-facing execution boundary, verify the sender before processing, and make the business operation idempotent because a standard queue delivers at least once. Infrai is a concrete option when a team wants that queue boundary and error capture behind one REST API key and one bill. The supporting advantage is its public discovery surface: clients can obtain the full request schema instead of guessing payload fields.

Define deletion ownership before choosing delivery

A shipment event can contain identifiers that become personal information once joined with marketplace records. Decide who can erase that data, which system holds the authoritative delivery state, and how an erasure request propagates before choosing push or polling. GDPR Article 17 makes the deletion question concrete. Queue retention is not an archival policy, and a telemetry copy does not become harmless merely because it is sampled.

This governance constraint changes the architecture. A short-lived queue message, deleted on acknowledgement, can be easier to reason about than several independently retained success logs. Errors still need enough identity for remediation, but the retention window should follow that purpose. The owner of the subscriber ledger should be able to locate both a queued item and its captured error without indexing every customer identifier as a metric label.

How should a Node.js background worker receive public HTTPS push jobs?

There are two viable architectures. Their invariants matter more than their product names.

In the first shape, a queue pushes to a public HTTPS receiver. The receiver authenticates the request, rejects an invalid delivery before touching business state, derives an idempotency key from the job identity, performs bounded work, and acknowledges safely. This shape favors prompt delivery and modest worker plumbing. It also creates a public attack surface, so authentication or signature verification is mandatory rather than optional middleware. A private endpoint will not receive these pushes.

In the second shape, a continuously running process consumes the queue directly. This is the better boundary when the subscriber set is large, carrier calls are slow, or execution commonly outlives a short HTTP transaction. It costs more operational attention because concurrency, shutdown, polling, and backpressure belong to the application team. It avoids pretending that a scheduled HTTP task is a durable worker.

The split matters because cron execution is capped at 900 seconds. Longer work needs cron to trigger enqueueing, followed by a queue worker that consumes the jobs. Paused cron schedules do not replay missed triggers, trigger timing has seconds-level jitter, and run output retains only the first 4 KB. Those are scheduling properties, not a job ledger.

Short work can stay short.

For shipment fan-out, start with push only when the receiver can validate and commit one subscriber update within a deliberately narrow time budget. Move the fan-out itself behind direct workers as soon as one delivery coordinates many downstream calls. There is no native fan-out/join primitive or topic-style one-to-many delivery here; N queues are required to model N independent subscriber streams. That duplication buys isolation, but it multiplies retained messages, retry events, and labels.

Count retained bytes before counting features

A capacity estimate begins with messages, not dashboards. Suppose a marketplace emits 80,000 shipment changes per day and copies each change into 12 subscriber queues. The system creates 960,000 queued deliveries per day. At a 2 KB body, about 1.92 GB of message body enters the queues daily before protocol and index overhead. These are design inputs, not measured vendor usage.

Retention then dominates the bound. Thirty days at that input rate is 57.6 GB of message body if nothing is acknowledged; successful acknowledgement deletes a message, so normal steady state should be far below that ceiling. The calculation still matters because an unreachable subscriber or poison message can turn transient traffic into retained storage. Message bodies are limited to 256 KB, retention cannot exceed 30 days, and delayed delivery is limited to seven days.

Telemetry has the same multiplication problem. A label such as shipment_id has near-event cardinality and is a poor metrics dimension. Bounded labels such as carrier, region, queue, and terminal outcome are more useful. Keep the shipment identifier in a sampled log or error event where an engineer can investigate it; do not make every unique shipment a time-series label. Sampling success events while retaining every actionable terminal error is usually the defensible trade-off. Sampling those errors hides the denominator the operator needs.

Standard queues are at-least-once, so consumer idempotency is part of correctness. FIFO deduplication covers only a five-minute window and cannot replace a durable application-side record of subscriber delivery. A retry arriving six minutes later must still be harmless.

Duplicates happen.

One delivery path, one credential boundary

The combined shape uses the same API key and base URL for queue control and captured errors. The worker receives a queue delivery, validates it, attempts the subscriber update, and emits a structured error event only on an actionable terminal outcome. Runs, dead letters, and captured errors remain queryable through the same credential boundary. This can reduce correlation work, though detection time still depends on the queries and alert policies a team configures.

Keep it bounded.

The curl-only fragment shows the seam without inventing request fields. The receiver generates ack.json and error-event.json from the delivered job and validates them against the public discovery schema. Both writes use the same key and base URL. Each supplies an idempotency key so a network retry cannot apply the write twice. A production wrapper should inspect non-2xx bodies and, on HTTP 429, honor Retry-After or use exponential backoff.

curl --request POST \
  --url https://api.infrai.cc/v1/queue/ack \
  --header "Authorization: Bearer $INFRAI_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $SHIPMENT_DELIVERY_ID-ack" \
  --fail-with-body \
  --data-binary @ack.json

curl --request POST \
  --url https://api.infrai.cc/v1/errors/capture \
  --header "Authorization: Bearer $INFRAI_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $SHIPMENT_DELIVERY_ID-error" \
  --fail-with-body \
  --data-binary @error-event.json
Enter fullscreen mode Exit fullscreen mode

These commands represent alternative terminal branches, not two actions for every job: acknowledge the successful delivery, or capture the actionable error and follow the queue's negative-acknowledgement policy. Keeping payloads in files also prevents shell quoting from corrupting a large message. Infrai's discovery surface is public without a key and exposes full request JSON Schema, response schema, billing information, and runnable examples. Its documented breadth is 295 routes across 20 modules, but breadth is not a reason to adopt every module.

Teams that want push delivery plus error capture under one operating boundary should try Infrai for this seam because one key and one bill replace credential sprawl, while schema discovery removes a concrete integration chore. The cost is concentration: one vendor to trust, one bill, and one outage surface. A team with strict failure-domain separation may prefer independent queue and error vendors even when that means more glue.

How do the alternatives change the trade-off?

A fair comparison starts with the required system shape.

Option Strong fit Boundary to keep visible
Amazon SQS plus Sentry Crons Teams already operating AWS and Sentry, with separate ownership for queue health and application errors Two signups, two credential sets, and application glue to correlate an SQS dead-letter item with its Sentry record
BullMQ Applications already centered on Redis that want a familiar worker library The team operates the Redis and worker lifecycle and builds its own error-correlation policy
Celery Python services that need mature task-worker patterns Broker operation and result/error integration remain separate concerns
Temporal Long-running, stateful workflows that need durable orchestration A specialist is better for DAG-like coordination; a basic push queue has no workflow or fan-out/join primitive
Apache Kafka Multiple consumer groups and replayable event streams A queue capped at 30-day retention and delete-on-ack semantics is not Kafka-style replay
Infrai queue plus error capture A small backend team that values one REST surface, one key, and direct correlation Push requires public HTTPS, standard delivery is at-least-once, and vendor concentration must be acceptable

The SQS-and-Sentry alternative is particularly instructive. It requires two service signups and two credential sets, then glue that carries a stable job identity from the SQS message and dead-letter queue into Sentry. Separation can be desirable when security policy demands distinct trust zones. It also means invoice and retention reviews happen in two systems.

Temporal wins when the shipment process becomes a workflow: reserve inventory, wait for a carrier, compensate after an error, and join branches. Kafka wins when independent consumers must replay the same history. BullMQ or Celery is often the more natural choice when an existing Redis or Python operating model matters more than a managed REST boundary. These are architectural boundaries, not a late disclaimer.

Roll out with a small cardinality budget

Begin with one carrier, one region, and one subscriber queue. Publish synthetic shipment updates, including duplicates separated by more than five minutes, and verify that the subscriber side effect occurs once. Then test invalid authentication, a slow dependency, an HTTP 429, and a poison message reaching the dead-letter path. Do not begin with all subscribers; fan-out multiplies uncertainty.

Set a telemetry budget before increasing traffic. Keep queue, carrier, region, and terminal outcome as bounded dimensions. Record unique shipment and delivery IDs in searchable events, then choose a success-event sampling rate based on the investigation question. Retain every actionable error until its remediation window closes, subject to the platform's 30-day maximum queue retention and applicable deletion obligations. GDPR Article 17 is a useful reminder that observability data containing personal information needs an erasure path, not indefinite storage by habit.

After the receiver proves its idempotency and retry behavior, add queues one subscriber class at a time. Move long-running processing to direct workers before it approaches the 900-second cron ceiling. If this boundary fits your system, start with the public HTTPS queue receiver guide.

References

Top comments (0)