Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Service Bus] Fix log message at actionAfterWaitTimeout #12322

Merged
merged 12 commits into from
Nov 10, 2020
Merged
2 changes: 1 addition & 1 deletion sdk/servicebus/service-bus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

### New features:

- A helper method `parseServiceBusConnectionString` has been added which validates and parses a given connection string for Azure Service Bus. You can use this to extract the namespace and entitypath details from the connection string.
- A helper method `parseServiceBusConnectionString` has been added which validates and parses a given connection string for Azure Service Bus. You can use this to extract the namespace and entityPath details from the connection string.
[PR 11949](https://github.com/Azure/azure-sdk-for-js/pull/11949)
- All methods that take an array as input are updated to ensure they gracefully do a no-op rather than throw errors. For example: `receiveDeferredMessages()`, `scheduleMessages()` and `cancelScheduledMessages()`.
- Tracing, using [@azure/core-tracing](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-tracing/README.md), has been added for sending and receiving of messages.
Expand Down
24 changes: 13 additions & 11 deletions sdk/servicebus/service-bus/src/core/batchingReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,13 @@ export class BatchingReceiverLite {
// a chance to have fewer messages internally that could get lost if the user's
// app crashes in receiveAndDelete mode.
if (totalWaitTimer) clearTimeout(totalWaitTimer);

totalWaitTimer = setTimeout(actionAfterWaitTimeout, getRemainingWaitTimeInMs());
const remainingWaitTimeInMs = getRemainingWaitTimeInMs();
totalWaitTimer = setTimeout(() => {
logger.verbose(
`${loggingPrefix} Batching, waited for ${remainingWaitTimeInMs} milliseconds after receiving the first message.`
);
finalAction();
}, remainingWaitTimeInMs);
}
}

Expand Down Expand Up @@ -486,14 +491,6 @@ export class BatchingReceiverLite {
reject(err);
}, args.abortSignal);

// Action to be performed after the max wait time is over.
const actionAfterWaitTimeout = (): void => {
logger.verbose(
`${loggingPrefix} Batching, max wait time in milliseconds ${args.maxWaitTimeInMs} over.`
);
return finalAction();
};

logger.verbose(
`${loggingPrefix} Adding credit for receiving ${args.maxMessageCount} messages.`
);
Expand All @@ -508,7 +505,12 @@ export class BatchingReceiverLite {
`${loggingPrefix} Setting the wait timer for ${args.maxWaitTimeInMs} milliseconds.`
);

totalWaitTimer = setTimeout(actionAfterWaitTimeout, args.maxWaitTimeInMs);
totalWaitTimer = setTimeout(() => {
logger.verbose(
`${loggingPrefix} Batching, waited for max wait time ${args.maxWaitTimeInMs} milliseconds.`
);
finalAction();
}, args.maxWaitTimeInMs);

receiver.on(ReceiverEvents.message, onReceiveMessage);
receiver.on(ReceiverEvents.receiverError, onError);
Expand Down