IO-3166-Global-Notifications-Part-2: Make sure BULLMQ prefixes do not collide

This commit is contained in:
Dave Richer
2025-03-12 20:00:53 -04:00
parent 87db292e5d
commit 360a1954f4
3 changed files with 19 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
const { Queue, Worker } = require("bullmq");
const { INSERT_NOTIFICATIONS_MUTATION } = require("../../graphql-client/queries");
const { registerCleanupTask } = require("../../utils/cleanupManager");
const getBullMQPrefix = require("../../utils/getBullMQPrefix");
const graphQLClient = require("../../graphql-client/graphql-client").client;
// Base time-related constant in minutes, sourced from environment variable or defaulting to 1
@@ -45,17 +46,19 @@ const buildNotificationContent = (notifications) => {
*/
const loadAppQueue = async ({ pubClient, logger, redisHelpers, ioRedis }) => {
if (!addQueue || !consolidateQueue) {
logger.logger.debug("Initializing Notifications Queues");
const prefix = getBullMQPrefix();
logger.logger.debug(`Initializing Notifications Queues with prefix: ${prefix}`);
addQueue = new Queue("notificationsAdd", {
prefix,
connection: pubClient,
prefix: "{BULLMQ}",
defaultJobOptions: { removeOnComplete: true, removeOnFail: true }
});
consolidateQueue = new Queue("notificationsConsolidate", {
prefix,
connection: pubClient,
prefix: "{BULLMQ}",
defaultJobOptions: { removeOnComplete: true, removeOnFail: true }
});
@@ -100,8 +103,8 @@ const loadAppQueue = async ({ pubClient, logger, redisHelpers, ioRedis }) => {
}
},
{
prefix,
connection: pubClient,
prefix: "{BULLMQ}",
concurrency: 5
}
);
@@ -227,8 +230,8 @@ const loadAppQueue = async ({ pubClient, logger, redisHelpers, ioRedis }) => {
}
},
{
prefix,
connection: pubClient,
prefix: "{BULLMQ}",
concurrency: 1,
limiter: { max: 1, duration: RATE_LIMITER_DURATION }
}