From 6997728ac589b213f09d5cb2becdb5a1475831dd Mon Sep 17 00:00:00 2001 From: Matt Cavanagh <1776058+Maelstromeous@users.noreply.github.com> Date: Tue, 29 Sep 2026 07:01:01 +0100 Subject: [PATCH] perf: declare api-queue-production memory-only, matching the aggregator Non-durable with no lazy mode, so RabbitMQ 3.10 stops writing every message to disk. Must match the aggregator's declaration, or whichever service declares second is refused with PRECONDITION_FAILED. A spec pins the options. Co-Authored-By: Claude Opus 5.5 --- src/config/index.spec.ts | 11 +++++++++++ src/config/index.ts | 6 ++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 src/config/index.spec.ts diff --git a/src/config/index.spec.ts b/src/config/index.spec.ts new file mode 100644 index 00000000..a163af85 --- /dev/null +++ b/src/config/index.spec.ts @@ -0,0 +1,11 @@ +import {config} from './index'; + +describe('rabbitmq queue options', () => { + // RabbitMQ refuses a redeclare with different arguments, so these must equal the aggregator's ApiQueue + it('declares the api queue memory-only, matching the aggregator', () => { + expect(config().rabbitmq.queueOptions).toEqual({ + durable: false, + messageTtl: 10800000, + }); + }); +}); diff --git a/src/config/index.ts b/src/config/index.ts index 3d99c928..70dffecb 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -32,12 +32,10 @@ export const config = () => ({ rabbitmq: { url: [process.env.RABBITMQ_URL ?? `amqp://${process.env.RABBITMQ_USER ?? 'guest'}:${process.env.RABBITMQ_PASS ?? 'guest'}@${process.env.RABBITMQ_HOST ?? 'localhost'}:5672${process.env.RABBITMQ_VHOST ?? ''}?heartbeat=10&connection_timeout=10000`], queue: process.env.RABBITMQ_QUEUE ?? 'api-queue', + // Memory-only, and must match the aggregator's ApiQueue declaration or whichever declares second fails queueOptions: { - durable: true, + durable: false, messageTtl: 10800000, // 3 hours - arguments: { - 'x-queue-mode': 'lazy', - }, }, noAck: false, prefetchCount: process.env.RABBITMQ_PREFETCH ? parseInt(process.env.RABBITMQ_PREFETCH, 10) : 2000,