Skip to content

Commit 8f0b81b

Browse files
authored
[ServiceBus] resolve received messages immediately when we got extra (Azure#23779)
The comments indicates that it is possible that we receive more messages than we ask for, and we want to return them. However, in current code we only resolve after max-wait-time-after-first message has passed once we have extra because of the length equality check, and during the wait time, more messages could still arrive. This PR changes to remove immediately when we get what we ask for or more.
1 parent ba2b448 commit 8f0b81b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

sdk/servicebus/service-bus/src/core/batchingReceiver.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,7 @@ export class BatchingReceiverLite {
459459
// silently dropped on the floor.
460460
if (brokeredMessages.length > args.maxMessageCount) {
461461
logger.warning(
462-
`More messages arrived than were expected: ${args.maxMessageCount} vs ${
463-
brokeredMessages.length + 1
464-
}`
462+
`More messages arrived than expected: ${args.maxMessageCount} vs ${brokeredMessages.length}`
465463
);
466464
}
467465
} catch (err: any) {
@@ -472,7 +470,7 @@ export class BatchingReceiverLite {
472470
);
473471
reject(errObj);
474472
}
475-
if (brokeredMessages.length === args.maxMessageCount) {
473+
if (brokeredMessages.length >= args.maxMessageCount) {
476474
this._finalAction!();
477475
}
478476
};

0 commit comments

Comments
 (0)