Skip to content

feat(queue): migrate webhook deliveries from Redis/BullMQ to RabbitMQ - #820

Merged
Abdulazeem-code merged 2 commits into
Abdulazeem-code:mainfrom
Chummy-debug:feat/backend-rabbitmq-migration-728
Oct 5, 2026
Merged

Abdulazeem-code merged 2 commits into
Abdulazeem-code:mainfrom
Chummy-debug:feat/backend-rabbitmq-migration-728

Conversation

@Chummy-debug

Copy link
Copy Markdown

Overview

Migrates the webhook delivery queue from Redis/BullMQ to RabbitMQ. Publishers now use a durable topic exchange with per-event routing keys and publisher confirms; consumers use manual acknowledgements, a TTL-based retry queue for exponential backoff, and a dead-letter queue for deliveries that exhaust their attempts. Redis stays in the stack for caching and rate limiting.

Related Issue

Addresses the RabbitMQ queue refactor requested in #728.

Changes

AMQP transport

  • [ADD] stellar-payment-platform/src/queue/rabbitmqQueue.js

    • Durable topology: stellar.webhooks (topic exchange), webhook-deliveries (work queue, webhook.# binding), webhook-deliveries.retry (per-message TTL + dead-letter back to the exchange) and webhook-deliveries.dlq (terminal).
    • Queue publishes persistent messages and awaits waitForConfirms() before an enqueue is treated as successful.
    • Worker runs the processor with a fixed concurrency, acks successes, republishes transient failures with a capped exponential TTL, and nacks exhausted jobs to the dead-letter exchange.
    • Shared connection with bounded reconnect backoff and a generic withQueueRetry for transient socket/broker errors.
  • [MODIFY] stellar-payment-platform/src/webhookWorker.js

    • Replaces bullmq Queue/Worker and the Redis connection with the AMQP transport.
    • Enqueues carry a routingKey derived from the event name; shutdown closes the worker, queue and shared AMQP connection.
    • Delivery, signature, retry-count and DB dead-letter semantics are unchanged.
  • [MODIFY] stellar-payment-platform/src/webhookWorker.main.js

    • Same transport swap for the pool-fallback worker variant.

Infrastructure & configuration

  • [MODIFY] docker-compose.yml
    • Adds a rabbitmq:3.13-management-alpine service (durable volume, healthcheck, AMQP 5672 + management 15672) and wires RABBITMQ_URL plus a depends_on health gate into the backend.
  • [MODIFY] stellar-payment-platform/.env.example
    • Documents RABBITMQ_URL and clarifies that REDIS_URL / REDIS_CLUSTER_NODES now serve caching and rate limiting only.
  • [ADD] stellar-payment-platform/docs/rabbitmq-queue.md
    • Documents the topology, durability guarantees and local setup.
  • [MODIFY] stellar-payment-platform/package.json
    • Adds amqplib and removes the now-unused bullmq dependency.

Tests

  • [MODIFY] stellar-payment-platform/tests/webhook-worker.test.js
    • Mocks the new transport and asserts the enqueue shape (attempts, backoff, routing key), worker startup, per-webhook fan-out, the retry helper and shutdown.
  • [ADD] stellar-payment-platform/tests/queue/rabbitmq-queue.test.js
    • Asserts the durable topology declarations, persistent publish + confirm, ack-on-success, retry-on-failure with exponential TTL, dead-lettering on exhausted attempts, and the retry/classifier helpers.

Verification Results

Implemented via GitHub Git Data API (no local clone).
Static checks run in this environment: `node --check` passes for
src/queue/rabbitmqQueue.js, src/webhookWorker.js and src/webhookWorker.main.js.

Jest was NOT executed in this environment (the task excludes cloning/installing
the repository), so the unit tests above are provided but not reported as run.
Acceptance Criteria Status
RabbitMQ infrastructure is provisioned ✅ docker-compose rabbitmq service (durable volume + healthcheck) and RABBITMQ_URL
Publishers and consumers are rewritten using AMQP ✅ src/queue/rabbitmqQueue.js replaces bullmq in both webhook workers
No jobs are lost during simulated broker restarts ✅ by design: persistent messages, durable queues/exchanges, publisher confirms, TTL retry queue and a durable DLQ (unit tests assert the ack/retry/DLQ routing)

Closes #728

@vercel

vercel Bot commented Sep 26, 2026

Copy link
Copy Markdown

@Chummy-debug is attempting to deploy a commit to the Abdulazeem's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Sep 26, 2026

Copy link
Copy Markdown

@Chummy-debug Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Abdulazeem-code

Copy link
Copy Markdown
Owner

Please resolve conflicts

@Abdulazeem-code

Copy link
Copy Markdown
Owner

Kindly fix failed checks

1 similar comment
@Abdulazeem-code

Copy link
Copy Markdown
Owner

Kindly fix failed checks

@Chummy-debug
Chummy-debug force-pushed the feat/backend-rabbitmq-migration-728 branch from 09dbfbb to dc019cc Compare October 4, 2026 17:32
@Abdulazeem-code

Copy link
Copy Markdown
Owner

Kindly resolve conflicts

@Abdulazeem-code
Abdulazeem-code merged commit 22b20d5 into Abdulazeem-code:main Oct 5, 2026
9 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend: Refactor the Queue System to use RabbitMQ

2 participants