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
4 changes: 3 additions & 1 deletion sdk/servicebus/service-bus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

## 7.0.0 (Unreleased)

- Log message for the `actionAfterWaitTimeout`(gets triggered for receiveMessages API) has been updated to reflect the cause of termination.

## 7.0.0-preview.8 (2020-11-04)

### 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
22 changes: 14 additions & 8 deletions sdk/servicebus/service-bus/src/core/batchingReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,12 @@ 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(() => {
actionAfterWaitTimeout(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the message is being passed to actionAfterWaitTimeout I'm not sure there's much value to even having actionAfterWaitTimeout be a separate function, but that's just a personal nit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. @HarshaNalluru, can we inline the code from actionAfterWaitTimeout here?

`Batching, waited for ${remainingWaitTimeInMs} milliseconds after receiving the first message.`
);
}, remainingWaitTimeInMs);
}
}

Expand Down Expand Up @@ -487,11 +491,9 @@ 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.`
);
// Action to be performed after the wait time is over.
const actionAfterWaitTimeout = (logMessage: string): void => {
logger.verbose(`${loggingPrefix} ${logMessage}`);
return finalAction();
};

Expand All @@ -509,7 +511,11 @@ export class BatchingReceiverLite {
`${loggingPrefix} Setting the wait timer for ${args.maxWaitTimeInMs} milliseconds.`
);

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

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