queen-mq 0.2.22 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@ const QUEUE_NAME = 'benchmark-queue-001';
|
|
|
5
5
|
const NUMBER_OF_CONSUMERS = 10;
|
|
6
6
|
const STARTING_PARTITION = parseInt(process.argv[2]) || 0;
|
|
7
7
|
const BATCH_SIZE = 10000;
|
|
8
|
-
const CONSUME_MODE = 'partition';
|
|
8
|
+
const CONSUME_MODE = null//'partition';
|
|
9
9
|
|
|
10
10
|
// Global metrics tracking
|
|
11
11
|
const metrics = {
|
|
@@ -542,14 +542,16 @@ export class Queen {
|
|
|
542
542
|
if (hasIndividualStatus) {
|
|
543
543
|
// Option B: Each message has its own status
|
|
544
544
|
acknowledgments = message.map(msg => {
|
|
545
|
-
// Extract transaction ID and lease ID
|
|
545
|
+
// Extract transaction ID, partition ID, and lease ID
|
|
546
546
|
let transactionId;
|
|
547
|
+
let partitionId = null;
|
|
547
548
|
let leaseId = null;
|
|
548
549
|
|
|
549
550
|
if (typeof msg === 'string') {
|
|
550
551
|
transactionId = msg;
|
|
551
552
|
} else if (typeof msg === 'object' && msg !== null) {
|
|
552
553
|
transactionId = msg.transactionId || msg.id;
|
|
554
|
+
partitionId = msg.partitionId || null;
|
|
553
555
|
leaseId = msg.leaseId || null;
|
|
554
556
|
if (!transactionId) {
|
|
555
557
|
throw new Error('Message object must have transactionId or id property');
|
|
@@ -573,6 +575,11 @@ export class Queen {
|
|
|
573
575
|
error: msg._error || context.error || null
|
|
574
576
|
};
|
|
575
577
|
|
|
578
|
+
// Include partition ID if available
|
|
579
|
+
if (partitionId) {
|
|
580
|
+
ack.partitionId = partitionId;
|
|
581
|
+
}
|
|
582
|
+
|
|
576
583
|
// Include lease ID if available
|
|
577
584
|
if (leaseId) {
|
|
578
585
|
ack.leaseId = leaseId;
|
|
@@ -587,14 +594,16 @@ export class Queen {
|
|
|
587
594
|
: status;
|
|
588
595
|
|
|
589
596
|
acknowledgments = message.map(msg => {
|
|
590
|
-
// Extract transaction ID and lease ID
|
|
597
|
+
// Extract transaction ID, partition ID, and lease ID
|
|
591
598
|
let transactionId;
|
|
599
|
+
let partitionId = null;
|
|
592
600
|
let leaseId = null;
|
|
593
601
|
|
|
594
602
|
if (typeof msg === 'string') {
|
|
595
603
|
transactionId = msg;
|
|
596
604
|
} else if (typeof msg === 'object' && msg !== null) {
|
|
597
605
|
transactionId = msg.transactionId || msg.id;
|
|
606
|
+
partitionId = msg.partitionId || null;
|
|
598
607
|
leaseId = msg.leaseId || null;
|
|
599
608
|
if (!transactionId) {
|
|
600
609
|
throw new Error('Message object must have transactionId or id property');
|
|
@@ -609,6 +618,11 @@ export class Queen {
|
|
|
609
618
|
error: context.error || null
|
|
610
619
|
};
|
|
611
620
|
|
|
621
|
+
// Include partition ID if available
|
|
622
|
+
if (partitionId) {
|
|
623
|
+
ack.partitionId = partitionId;
|
|
624
|
+
}
|
|
625
|
+
|
|
612
626
|
// Include lease ID if available
|
|
613
627
|
if (leaseId) {
|
|
614
628
|
ack.leaseId = leaseId;
|
|
@@ -636,14 +650,16 @@ export class Queen {
|
|
|
636
650
|
}
|
|
637
651
|
|
|
638
652
|
// Handle single message acknowledgment
|
|
639
|
-
// Extract transaction ID and lease ID
|
|
653
|
+
// Extract transaction ID, partition ID, and lease ID
|
|
640
654
|
let transactionId;
|
|
655
|
+
let partitionId = null;
|
|
641
656
|
let leaseId = null;
|
|
642
657
|
|
|
643
658
|
if (typeof message === 'string') {
|
|
644
659
|
transactionId = message;
|
|
645
660
|
} else if (typeof message === 'object' && message !== null) {
|
|
646
661
|
transactionId = message.transactionId || message.id;
|
|
662
|
+
partitionId = message.partitionId || null; // Extract partition ID for partition-scoped ACK
|
|
647
663
|
leaseId = message.leaseId || null; // Extract lease ID if present
|
|
648
664
|
if (!transactionId) {
|
|
649
665
|
throw new Error('Message object must have transactionId or id property');
|
|
@@ -668,6 +684,11 @@ export class Queen {
|
|
|
668
684
|
consumerGroup: context.group || null
|
|
669
685
|
};
|
|
670
686
|
|
|
687
|
+
// Include partition ID if available for partition-scoped operations
|
|
688
|
+
if (partitionId) {
|
|
689
|
+
body.partitionId = partitionId;
|
|
690
|
+
}
|
|
691
|
+
|
|
671
692
|
// Include lease ID if available for lease validation
|
|
672
693
|
if (leaseId) {
|
|
673
694
|
body.leaseId = leaseId;
|