From 15abce8b7610749ae115841b5d797fe7d0500b4c Mon Sep 17 00:00:00 2001 From: Timothee Legros Date: Sat, 7 Sep 2024 07:46:21 +0300 Subject: [PATCH] DISABLE_LOCAL_QUEUE_PURGE env var --- libs/adapters/src/config.ts | 7 +++++++ libs/adapters/src/rabbitmq/rabbitMQConfig.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/adapters/src/config.ts b/libs/adapters/src/config.ts index 97389ae41ae..98a6c44245f 100644 --- a/libs/adapters/src/config.ts +++ b/libs/adapters/src/config.ts @@ -29,6 +29,7 @@ const { SEND_WEBHOOKS, SEND_WEBHOOKS_CONFIRMATION_TIMESTAMP, SEND_EMAILS, + DISABLE_LOCAL_QUEUE_PURGE, } = process.env; export const config = configure( @@ -42,6 +43,7 @@ export const config = configure( }, BROKER: { RABBITMQ_URI: CLOUDAMQP_URL ?? DEFAULTS.RABBITMQ_URI, + DISABLE_LOCAL_QUEUE_PURGE: DISABLE_LOCAL_QUEUE_PURGE === 'true', }, NOTIFICATIONS: { FLAG_KNOCK_INTEGRATION_ENABLED: @@ -95,6 +97,11 @@ export const config = configure( data === DEFAULTS.RABBITMQ_URI ); }, 'RABBITMQ_URI is require in production, beta (QA), demo, and frick Heroku apps'), + DISABLE_LOCAL_QUEUE_PURGE: z + .boolean() + .describe( + 'Disable purging all messages in queues when a consumer starts up', + ), }), NOTIFICATIONS: z .object({ diff --git a/libs/adapters/src/rabbitmq/rabbitMQConfig.ts b/libs/adapters/src/rabbitmq/rabbitMQConfig.ts index 9f19050e3ac..7c810bcb82b 100644 --- a/libs/adapters/src/rabbitmq/rabbitMQConfig.ts +++ b/libs/adapters/src/rabbitmq/rabbitMQConfig.ts @@ -1,4 +1,5 @@ import * as Rascal from 'rascal'; +import { config as EnvConfig } from '../config'; import { getAllRascalConfigs } from './configuration/rascalConfig'; import { RascalBindings, @@ -31,7 +32,7 @@ export function getRabbitMQConfig( rabbitmq_uri.includes('127.0.0.1') ) { vhost = '/'; - purge = true; + purge = !EnvConfig.BROKER.DISABLE_LOCAL_QUEUE_PURGE; } else { const count = (rabbitmq_uri.match(/\//g) || []).length; if (count == 3) {