@@ -108,6 +108,7 @@ export class BatchQueue {
108108 keys : keyProducer ,
109109 quantum : options . drr . quantum ,
110110 maxDeficit : options . drr . maxDeficit ,
111+ masterQueueLimit : options . drr . masterQueueLimit ,
111112 logger : {
112113 debug : ( msg , ctx ) => this . logger . debug ( msg , ctx ) ,
113114 error : ( msg , ctx ) => this . logger . error ( msg , ctx ) ,
@@ -121,7 +122,7 @@ export class BatchQueue {
121122 scheduler,
122123 payloadSchema : BatchItemPayloadSchema ,
123124 validateOnEnqueue : false , // We control the payload
124- shardCount : 1 , // Batches don't need sharding
125+ shardCount : options . shardCount ?? 1 ,
125126 consumerCount : options . consumerCount ,
126127 consumerIntervalMs : options . consumerIntervalMs ,
127128 visibilityTimeoutMs : 60_000 , // 1 minute for batch item processing
@@ -131,6 +132,14 @@ export class BatchQueue {
131132 threshold : 5 ,
132133 periodMs : 5_000 ,
133134 } ,
135+ // Enable two-stage processing with worker queues for better parallelism (when configured)
136+ // Worker queues provide better concurrency by separating queue selection from message processing
137+ workerQueue : options . workerQueueBlockingTimeoutSeconds
138+ ? {
139+ enabled : true ,
140+ blockingTimeoutSeconds : options . workerQueueBlockingTimeoutSeconds ,
141+ }
142+ : undefined ,
134143 // Concurrency group based on tenant (environment)
135144 // This limits how many batch items can be processed concurrently per environment
136145 // Items wait in queue until capacity frees up
0 commit comments