Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions samples/mastra-extended/app/src/lib/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import IORedis from "ioredis";
import { Queue } from "bullmq";

export const QUEUE_NAME = process.env.QUEUE_NAME ?? "support-sync";
// Hash-tag wrapping forces every BullMQ key for this queue (wait/active/events/…)
// onto the same Redis cluster slot, so multi-key Lua scripts don't trip CROSSSLOT
// on sharded backends like Azure Managed Redis.
export const QUEUE_PREFIX = `{${QUEUE_NAME}}`;

declare global {
// eslint-disable-next-line no-var
Expand Down Expand Up @@ -29,6 +33,7 @@ export function getSyncQueue() {
if (!global.syncQueue) {
global.syncQueue = new Queue(QUEUE_NAME, {
connection: getRedisConnection(),
prefix: QUEUE_PREFIX,
});
}

Expand Down
3 changes: 2 additions & 1 deletion samples/mastra-extended/app/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
startSeedRun,
updateProcessedItem,
} from "@/lib/items";
import { QUEUE_NAME, getRedisConnection, getSyncQueue } from "@/lib/queue";
import { QUEUE_NAME, QUEUE_PREFIX, getRedisConnection, getSyncQueue } from "@/lib/queue";

type SeedBatchJob = {
runId: string;
Expand Down Expand Up @@ -100,6 +100,7 @@ async function main() {
{
connection: getRedisConnection(),
concurrency: Number(process.env.WORKER_CONCURRENCY ?? 8),
prefix: QUEUE_PREFIX,
},
);

Expand Down
Loading