From 1fdc360a4d08e046a13adb25a6af2978b7a3edc7 Mon Sep 17 00:00:00 2001 From: Ramya Raja Date: Fri, 1 Nov 2019 16:05:47 -0700 Subject: [PATCH] Workaround for #5757 bug --- sdk/servicebus/service-bus/src/core/batchingReceiver.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk/servicebus/service-bus/src/core/batchingReceiver.ts b/sdk/servicebus/service-bus/src/core/batchingReceiver.ts index a52027161be4..72f838783e16 100644 --- a/sdk/servicebus/service-bus/src/core/batchingReceiver.ts +++ b/sdk/servicebus/service-bus/src/core/batchingReceiver.ts @@ -186,6 +186,8 @@ export class BatchingReceiver extends MessageReceiver { } if (brokeredMessages.length === maxMessageCount) { finalAction(); + } else { + addCreditAndSetTimer(true); } }; @@ -361,10 +363,13 @@ export class BatchingReceiver extends MessageReceiver { // number of messages concurrently. We will return the user an array of messages that can // be of size upto maxMessageCount. Then the user needs to accordingly dispose // (complete,/abandon/defer/deadletter) the messages from the array. - this._receiver!.addCredit(maxMessageCount); + this._receiver!.addCredit(1); let msg: string = "[%s] Setting the wait timer for %d seconds for receiver '%s'."; if (reuse) msg += " Receiver link already present, hence reusing it."; log.batching(msg, this._context.namespace.connectionId, idleTimeoutInSeconds, this.name); + if (totalWaitTimer) { + clearTimeout(totalWaitTimer); + } totalWaitTimer = setTimeout( actionAfterWaitTimeout, (idleTimeoutInSeconds as number) * 1000