@azure/service-bus 7.10.0-beta.2 → 7.10.0-beta.3
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.
- package/dist/browser/connectionContext.js +1 -2
- package/dist/browser/connectionContext.js.map +1 -1
- package/dist/browser/constructorHelpers.js +3 -4
- package/dist/browser/constructorHelpers.js.map +1 -1
- package/dist/browser/core/autoLockRenewer.js +9 -5
- package/dist/browser/core/autoLockRenewer.js.map +1 -1
- package/dist/browser/core/batchingReceiver.js +26 -18
- package/dist/browser/core/batchingReceiver.js.map +1 -1
- package/dist/browser/core/linkEntity.js +74 -13
- package/dist/browser/core/linkEntity.js.map +1 -1
- package/dist/browser/core/managementClient.js +48 -48
- package/dist/browser/core/managementClient.js.map +1 -1
- package/dist/browser/core/messageReceiver.js +41 -14
- package/dist/browser/core/messageReceiver.js.map +1 -1
- package/dist/browser/core/messageSender.js +33 -10
- package/dist/browser/core/messageSender.js.map +1 -1
- package/dist/browser/core/receiverHelper.js +3 -2
- package/dist/browser/core/receiverHelper.js.map +1 -1
- package/dist/browser/core/shared.js +11 -4
- package/dist/browser/core/shared.js.map +1 -1
- package/dist/browser/core/streamingReceiver.js +74 -43
- package/dist/browser/core/streamingReceiver.js.map +1 -1
- package/dist/browser/diagnostics/instrumentServiceBusMessage.js +16 -8
- package/dist/browser/diagnostics/instrumentServiceBusMessage.js.map +1 -1
- package/dist/browser/receivers/receiver.js +68 -23
- package/dist/browser/receivers/receiver.js.map +1 -1
- package/dist/browser/receivers/receiverCommon.js +36 -21
- package/dist/browser/receivers/receiverCommon.js.map +1 -1
- package/dist/browser/receivers/sessionReceiver.js +69 -29
- package/dist/browser/receivers/sessionReceiver.js.map +1 -1
- package/dist/browser/sender.js +33 -11
- package/dist/browser/sender.js.map +1 -1
- package/dist/browser/serializers/queueResourceSerializer.js +9 -1
- package/dist/browser/serializers/queueResourceSerializer.js.map +1 -1
- package/dist/browser/serializers/ruleResourceSerializer.js +1 -2
- package/dist/browser/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist/browser/serviceBusAtomManagementClient.js +181 -228
- package/dist/browser/serviceBusAtomManagementClient.js.map +1 -1
- package/dist/browser/serviceBusClient.js +31 -22
- package/dist/browser/serviceBusClient.js.map +1 -1
- package/dist/browser/serviceBusError.js +21 -1
- package/dist/browser/serviceBusError.js.map +1 -1
- package/dist/browser/serviceBusMessage.js +208 -13
- package/dist/browser/serviceBusMessage.js.map +1 -1
- package/dist/browser/serviceBusMessageBatch.js +32 -8
- package/dist/browser/serviceBusMessageBatch.js.map +1 -1
- package/dist/browser/serviceBusRuleManager.js +39 -15
- package/dist/browser/serviceBusRuleManager.js.map +1 -1
- package/dist/browser/session/messageSession.js +130 -25
- package/dist/browser/session/messageSession.js.map +1 -1
- package/dist/browser/util/atomXmlHelper.js +4 -5
- package/dist/browser/util/atomXmlHelper.js.map +1 -1
- package/dist/browser/util/compat/httpHeaders.js +1 -0
- package/dist/browser/util/compat/httpHeaders.js.map +1 -1
- package/dist/browser/util/constants.js +1 -1
- package/dist/browser/util/constants.js.map +1 -1
- package/dist/browser/util/sasServiceClientCredentials.js +8 -0
- package/dist/browser/util/sasServiceClientCredentials.js.map +1 -1
- package/dist/browser/util/semaphore.js +6 -2
- package/dist/browser/util/semaphore.js.map +1 -1
- package/dist/browser/util/utils.js +5 -7
- package/dist/browser/util/utils.js.map +1 -1
- package/dist/commonjs/connectionContext.js +1 -2
- package/dist/commonjs/connectionContext.js.map +1 -1
- package/dist/commonjs/constructorHelpers.js +3 -4
- package/dist/commonjs/constructorHelpers.js.map +1 -1
- package/dist/commonjs/core/autoLockRenewer.js +9 -5
- package/dist/commonjs/core/autoLockRenewer.js.map +1 -1
- package/dist/commonjs/core/batchingReceiver.js +26 -18
- package/dist/commonjs/core/batchingReceiver.js.map +1 -1
- package/dist/commonjs/core/linkEntity.js +74 -13
- package/dist/commonjs/core/linkEntity.js.map +1 -1
- package/dist/commonjs/core/managementClient.js +48 -48
- package/dist/commonjs/core/managementClient.js.map +1 -1
- package/dist/commonjs/core/messageReceiver.js +41 -14
- package/dist/commonjs/core/messageReceiver.js.map +1 -1
- package/dist/commonjs/core/messageSender.js +33 -10
- package/dist/commonjs/core/messageSender.js.map +1 -1
- package/dist/commonjs/core/receiverHelper.js +3 -2
- package/dist/commonjs/core/receiverHelper.js.map +1 -1
- package/dist/commonjs/core/shared.js +11 -4
- package/dist/commonjs/core/shared.js.map +1 -1
- package/dist/commonjs/core/streamingReceiver.js +74 -43
- package/dist/commonjs/core/streamingReceiver.js.map +1 -1
- package/dist/commonjs/diagnostics/instrumentServiceBusMessage.js +16 -8
- package/dist/commonjs/diagnostics/instrumentServiceBusMessage.js.map +1 -1
- package/dist/commonjs/receivers/receiver.js +68 -23
- package/dist/commonjs/receivers/receiver.js.map +1 -1
- package/dist/commonjs/receivers/receiverCommon.js +36 -21
- package/dist/commonjs/receivers/receiverCommon.js.map +1 -1
- package/dist/commonjs/receivers/sessionReceiver.js +69 -29
- package/dist/commonjs/receivers/sessionReceiver.js.map +1 -1
- package/dist/commonjs/sender.js +33 -11
- package/dist/commonjs/sender.js.map +1 -1
- package/dist/commonjs/serializers/queueResourceSerializer.js +9 -1
- package/dist/commonjs/serializers/queueResourceSerializer.js.map +1 -1
- package/dist/commonjs/serializers/ruleResourceSerializer.js +1 -2
- package/dist/commonjs/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist/commonjs/serviceBusAtomManagementClient.js +181 -227
- package/dist/commonjs/serviceBusAtomManagementClient.js.map +1 -1
- package/dist/commonjs/serviceBusClient.js +31 -22
- package/dist/commonjs/serviceBusClient.js.map +1 -1
- package/dist/commonjs/serviceBusError.js +21 -1
- package/dist/commonjs/serviceBusError.js.map +1 -1
- package/dist/commonjs/serviceBusMessage.js +208 -12
- package/dist/commonjs/serviceBusMessage.js.map +1 -1
- package/dist/commonjs/serviceBusMessageBatch.js +32 -8
- package/dist/commonjs/serviceBusMessageBatch.js.map +1 -1
- package/dist/commonjs/serviceBusRuleManager.js +39 -15
- package/dist/commonjs/serviceBusRuleManager.js.map +1 -1
- package/dist/commonjs/session/messageSession.js +130 -25
- package/dist/commonjs/session/messageSession.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/util/atomXmlHelper.js +4 -5
- package/dist/commonjs/util/atomXmlHelper.js.map +1 -1
- package/dist/commonjs/util/compat/httpHeaders.js +1 -0
- package/dist/commonjs/util/compat/httpHeaders.js.map +1 -1
- package/dist/commonjs/util/constants.js +1 -1
- package/dist/commonjs/util/constants.js.map +1 -1
- package/dist/commonjs/util/runtimeInfo.js +2 -2
- package/dist/commonjs/util/runtimeInfo.js.map +1 -1
- package/dist/commonjs/util/sasServiceClientCredentials.js +8 -0
- package/dist/commonjs/util/sasServiceClientCredentials.js.map +1 -1
- package/dist/commonjs/util/semaphore.js +6 -2
- package/dist/commonjs/util/semaphore.js.map +1 -1
- package/dist/commonjs/util/utils.js +5 -7
- package/dist/commonjs/util/utils.js.map +1 -1
- package/dist/esm/connectionContext.js +1 -2
- package/dist/esm/connectionContext.js.map +1 -1
- package/dist/esm/constructorHelpers.js +3 -4
- package/dist/esm/constructorHelpers.js.map +1 -1
- package/dist/esm/core/autoLockRenewer.js +9 -5
- package/dist/esm/core/autoLockRenewer.js.map +1 -1
- package/dist/esm/core/batchingReceiver.js +26 -18
- package/dist/esm/core/batchingReceiver.js.map +1 -1
- package/dist/esm/core/linkEntity.js +74 -13
- package/dist/esm/core/linkEntity.js.map +1 -1
- package/dist/esm/core/managementClient.js +48 -48
- package/dist/esm/core/managementClient.js.map +1 -1
- package/dist/esm/core/messageReceiver.js +41 -14
- package/dist/esm/core/messageReceiver.js.map +1 -1
- package/dist/esm/core/messageSender.js +33 -10
- package/dist/esm/core/messageSender.js.map +1 -1
- package/dist/esm/core/receiverHelper.js +3 -2
- package/dist/esm/core/receiverHelper.js.map +1 -1
- package/dist/esm/core/shared.js +11 -4
- package/dist/esm/core/shared.js.map +1 -1
- package/dist/esm/core/streamingReceiver.js +74 -43
- package/dist/esm/core/streamingReceiver.js.map +1 -1
- package/dist/esm/diagnostics/instrumentServiceBusMessage.js +16 -8
- package/dist/esm/diagnostics/instrumentServiceBusMessage.js.map +1 -1
- package/dist/esm/receivers/receiver.js +68 -23
- package/dist/esm/receivers/receiver.js.map +1 -1
- package/dist/esm/receivers/receiverCommon.js +36 -21
- package/dist/esm/receivers/receiverCommon.js.map +1 -1
- package/dist/esm/receivers/sessionReceiver.js +69 -29
- package/dist/esm/receivers/sessionReceiver.js.map +1 -1
- package/dist/esm/sender.js +33 -11
- package/dist/esm/sender.js.map +1 -1
- package/dist/esm/serializers/queueResourceSerializer.js +9 -1
- package/dist/esm/serializers/queueResourceSerializer.js.map +1 -1
- package/dist/esm/serializers/ruleResourceSerializer.js +1 -2
- package/dist/esm/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist/esm/serviceBusAtomManagementClient.js +181 -228
- package/dist/esm/serviceBusAtomManagementClient.js.map +1 -1
- package/dist/esm/serviceBusClient.js +31 -22
- package/dist/esm/serviceBusClient.js.map +1 -1
- package/dist/esm/serviceBusError.js +21 -1
- package/dist/esm/serviceBusError.js.map +1 -1
- package/dist/esm/serviceBusMessage.js +208 -13
- package/dist/esm/serviceBusMessage.js.map +1 -1
- package/dist/esm/serviceBusMessageBatch.js +32 -8
- package/dist/esm/serviceBusMessageBatch.js.map +1 -1
- package/dist/esm/serviceBusRuleManager.js +39 -15
- package/dist/esm/serviceBusRuleManager.js.map +1 -1
- package/dist/esm/session/messageSession.js +130 -25
- package/dist/esm/session/messageSession.js.map +1 -1
- package/dist/esm/util/atomXmlHelper.js +4 -5
- package/dist/esm/util/atomXmlHelper.js.map +1 -1
- package/dist/esm/util/compat/httpHeaders.js +1 -0
- package/dist/esm/util/compat/httpHeaders.js.map +1 -1
- package/dist/esm/util/constants.js +1 -1
- package/dist/esm/util/constants.js.map +1 -1
- package/dist/esm/util/runtimeInfo.js +1 -1
- package/dist/esm/util/runtimeInfo.js.map +1 -1
- package/dist/esm/util/sasServiceClientCredentials.js +8 -0
- package/dist/esm/util/sasServiceClientCredentials.js.map +1 -1
- package/dist/esm/util/semaphore.js +6 -2
- package/dist/esm/util/semaphore.js.map +1 -1
- package/dist/esm/util/utils.js +5 -7
- package/dist/esm/util/utils.js.map +1 -1
- package/dist/react-native/connectionContext.js +1 -2
- package/dist/react-native/connectionContext.js.map +1 -1
- package/dist/react-native/constructorHelpers.js +3 -4
- package/dist/react-native/constructorHelpers.js.map +1 -1
- package/dist/react-native/core/autoLockRenewer.js +9 -5
- package/dist/react-native/core/autoLockRenewer.js.map +1 -1
- package/dist/react-native/core/batchingReceiver.js +26 -18
- package/dist/react-native/core/batchingReceiver.js.map +1 -1
- package/dist/react-native/core/linkEntity.js +74 -13
- package/dist/react-native/core/linkEntity.js.map +1 -1
- package/dist/react-native/core/managementClient.js +48 -48
- package/dist/react-native/core/managementClient.js.map +1 -1
- package/dist/react-native/core/messageReceiver.js +41 -14
- package/dist/react-native/core/messageReceiver.js.map +1 -1
- package/dist/react-native/core/messageSender.js +33 -10
- package/dist/react-native/core/messageSender.js.map +1 -1
- package/dist/react-native/core/receiverHelper.js +3 -2
- package/dist/react-native/core/receiverHelper.js.map +1 -1
- package/dist/react-native/core/shared.js +11 -4
- package/dist/react-native/core/shared.js.map +1 -1
- package/dist/react-native/core/streamingReceiver.js +74 -43
- package/dist/react-native/core/streamingReceiver.js.map +1 -1
- package/dist/react-native/diagnostics/instrumentServiceBusMessage.js +16 -8
- package/dist/react-native/diagnostics/instrumentServiceBusMessage.js.map +1 -1
- package/dist/react-native/receivers/receiver.js +68 -23
- package/dist/react-native/receivers/receiver.js.map +1 -1
- package/dist/react-native/receivers/receiverCommon.js +36 -21
- package/dist/react-native/receivers/receiverCommon.js.map +1 -1
- package/dist/react-native/receivers/sessionReceiver.js +69 -29
- package/dist/react-native/receivers/sessionReceiver.js.map +1 -1
- package/dist/react-native/sender.js +33 -11
- package/dist/react-native/sender.js.map +1 -1
- package/dist/react-native/serializers/queueResourceSerializer.js +9 -1
- package/dist/react-native/serializers/queueResourceSerializer.js.map +1 -1
- package/dist/react-native/serializers/ruleResourceSerializer.js +1 -2
- package/dist/react-native/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist/react-native/serviceBusAtomManagementClient.js +181 -228
- package/dist/react-native/serviceBusAtomManagementClient.js.map +1 -1
- package/dist/react-native/serviceBusClient.js +31 -22
- package/dist/react-native/serviceBusClient.js.map +1 -1
- package/dist/react-native/serviceBusError.js +21 -1
- package/dist/react-native/serviceBusError.js.map +1 -1
- package/dist/react-native/serviceBusMessage.js +208 -13
- package/dist/react-native/serviceBusMessage.js.map +1 -1
- package/dist/react-native/serviceBusMessageBatch.js +32 -8
- package/dist/react-native/serviceBusMessageBatch.js.map +1 -1
- package/dist/react-native/serviceBusRuleManager.js +39 -15
- package/dist/react-native/serviceBusRuleManager.js.map +1 -1
- package/dist/react-native/session/messageSession.js +130 -25
- package/dist/react-native/session/messageSession.js.map +1 -1
- package/dist/react-native/util/atomXmlHelper.js +4 -5
- package/dist/react-native/util/atomXmlHelper.js.map +1 -1
- package/dist/react-native/util/compat/httpHeaders.js +1 -0
- package/dist/react-native/util/compat/httpHeaders.js.map +1 -1
- package/dist/react-native/util/constants.js +1 -1
- package/dist/react-native/util/constants.js.map +1 -1
- package/dist/react-native/util/sasServiceClientCredentials.js +8 -0
- package/dist/react-native/util/sasServiceClientCredentials.js.map +1 -1
- package/dist/react-native/util/semaphore.js +6 -2
- package/dist/react-native/util/semaphore.js.map +1 -1
- package/dist/react-native/util/utils.js +5 -7
- package/dist/react-native/util/utils.js.map +1 -1
- package/package.json +38 -38
|
@@ -74,10 +74,9 @@ function getNumberOfReceivers(connectionContext, receiverType) {
|
|
|
74
74
|
export var ConnectionContext;
|
|
75
75
|
(function (ConnectionContext) {
|
|
76
76
|
function create(config, tokenCredential, options) {
|
|
77
|
-
var _a;
|
|
78
77
|
if (!options)
|
|
79
78
|
options = {};
|
|
80
|
-
const userAgent = `${formatUserAgentPrefix(
|
|
79
|
+
const userAgent = `${formatUserAgentPrefix(options.userAgentOptions?.userAgentPrefix)} ${getRuntimeInfo()}`;
|
|
81
80
|
const parameters = {
|
|
82
81
|
config: config,
|
|
83
82
|
// re-enabling this will be a post-GA discussion similar to event-hubs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionContext.js","sourceRoot":"","sources":["../../src/connectionContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,gBAAgB,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAUzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA4GvD;;;GAGG;AACH,KAAK,UAAU,yBAAyB,CACtC,iBAAoC,EACpC,wBAAyE,EACzE,YAAoC;IAEpC,MAAM,WAAW,GAAoB,EAAE,CAAC;IAExC,+DAA+D;IAC/D,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC3E,MAAM,QAAQ,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAClE,IAAI,QAAQ,IAAI,QAAQ,CAAC,YAAY,KAAK,YAAY,EAAE,CAAC;YACvD,MAAM,CAAC,OAAO,CACZ,4CAA4C,EAC5C,iBAAiB,CAAC,UAAU,CAAC,EAAE,EAC/B,QAAQ,CA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E,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBACrE,GAAG,4BAA4B,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;aACjF,CAAC,CAAC;YAEH,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,iCAAiC,CAAC,CAAC;YAC9D,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YAEjC,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,0CAA0C,CAAC,CAAC;YACvE,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACjC,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;YACxC,MAAM,CAAC,OAAO,CAAC,IAAI,SAAS,wDAAwD,CAAC,CAAC;QACxF,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3E,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,SAAS,iDAAiD,CAAC,CAAC;YACpF,MAAM,MAAM,CAAC;QACf,CAAC;IACH,CAAC;IAhCqB,uBAAK,QAgC1B,CAAA;AACH,CAAC,EAjZgB,iBAAiB,KAAjB,iBAAiB,QAiZjC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { connectionLogger as logger } from \"./log.js\";\nimport { packageJsonInfo } from \"./util/constants.js\";\nimport type {\n ConnectionConfig,\n CreateConnectionContextBaseParameters,\n SasTokenProvider,\n} from \"@azure/core-amqp\";\nimport { ConnectionContextBase } from \"@azure/core-amqp\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { ServiceBusClientOptions } from \"./constructorHelpers.js\";\nimport type {\n AmqpError,\n Connection,\n ConnectionError,\n EventContext,\n OnAmqpEvent,\n} from \"rhea-promise\";\nimport { ConnectionEvents } from \"rhea-promise\";\nimport type { MessageSender } from \"./core/messageSender.js\";\nimport type { MessageSession } from \"./session/messageSession.js\";\nimport type { MessageReceiver } from \"./core/messageReceiver.js\";\nimport { ManagementClient } from \"./core/managementClient.js\";\nimport { formatUserAgentPrefix } from \"./util/utils.js\";\nimport { getRuntimeInfo } from \"./util/runtimeInfo.js\";\nimport type { NonSessionReceiverType, ReceiverType } from \"./core/linkEntity.js\";\nimport { ServiceBusError } from \"./serviceBusError.js\";\n\n/**\n * @internal\n * Provides contextual information like the underlying amqp connection, cbs session, management session,\n * tokenCredential, senders, receivers, etc. about the ServiceBus client.\n */\nexport interface ConnectionContext extends ConnectionContextBase {\n /**\n * The credential to be used for Authentication.\n * Default value: SasTokenProvider.\n */\n tokenCredential: SasTokenProvider | TokenCredential;\n /**\n * A map of active Service Bus Senders with sender name as key.\n */\n senders: { [name: string]: MessageSender };\n /**\n * A map of active Service Bus receivers for non session enabled queues/subscriptions\n * with receiver name as key.\n */\n messageReceivers: { [name: string]: MessageReceiver };\n /**\n * A map of active Service Bus receivers for session enabled queues/subscriptions\n * with receiver name as key.\n */\n messageSessions: { [name: string]: MessageSession };\n /**\n * A map of ManagementClient instances for operations over the $management link\n * with key as the entity path.\n */\n managementClients: { [name: string]: ManagementClient };\n /**\n * Function returning a promise that resolves once the connectionContext is ready to open an AMQP link.\n * ConnectionContext will be ready to open an AMQP link when:\n * - The AMQP connection is already open on both sides.\n * - The AMQP connection has been closed or disconnected. In this case, a new AMQP connection is expected\n * to be created first.\n * An AMQP link cannot be opened if the AMQP connection\n * is in the process of closing or disconnecting.\n */\n readyToOpenLink(): Promise<void>;\n /**\n * Fetches the receiver from the cache in ConnectionContext based on the receiverName given.\n * Useful for when a message needs to be settled or have its lock renewed.\n *\n * TODO: Track the right receiver on the message instead of the ConnectionContext to remove\n * the need for this helper.\n */\n getReceiverFromCache(\n receiverName: string,\n sessionId?: string,\n ): MessageReceiver | MessageSession | undefined;\n /**\n * Gets the management client for given entity path from the cache\n * Creates one if none exists in the cache\n */\n getManagementClient(entityPath: string): ManagementClient;\n /**\n * Indicates whether the connection is in the process of closing.\n * When this returns `true`, a `disconnected` event will be received\n * after the connection is closed.\n */\n isConnectionClosing(): boolean;\n}\n\n/**\n * Describes the members on the ConnectionContext that are only\n * used by it internally.\n * @hidden\n * @internal\n */\nexport interface ConnectionContextInternalMembers extends ConnectionContext {\n /**\n * Resolves once the context's connection emits a `disconnected` event.\n */\n waitForDisconnectedEvent(): Promise<void>;\n /**\n * Resolves once the connection has finished being reset.\n * Connections are reset as part of reacting to a `disconnected` event.\n */\n waitForConnectionReset(): Promise<void>;\n}\n\n/**\n * @internal\n * Helper type to get the names of all the functions on an object.\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];\n/**\n * @internal\n * Helper type to get the types of all the functions on an object.\n */\ntype FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;\n/**\n * @internal\n * Helper type to get the types of all the functions on ConnectionContext\n * and the internal methods from ConnectionContextInternalMembers.\n * Note that this excludes the functions that ConnectionContext inherits.\n * Each function also has its `this` type set as `ConnectionContext`.\n */\ntype ConnectionContextMethods = Omit<\n FunctionProperties<ConnectionContextInternalMembers>,\n FunctionPropertyNames<ConnectionContextBase>\n> &\n ThisType<ConnectionContextInternalMembers>;\n\n/**\n * @internal\n * Helper method to call onDetached on the non-sessions batching and streaming receivers from the connection context upon seeing an error.\n */\nasync function callOnDetachedOnReceivers(\n connectionContext: ConnectionContext,\n contextOrConnectionError: Error | ConnectionError | AmqpError | undefined,\n receiverType: NonSessionReceiverType,\n): Promise<void[]> {\n const detachCalls: Promise<void>[] = [];\n\n // Iterating over non-sessions batching and streaming receivers\n for (const receiverName of Object.keys(connectionContext.messageReceivers)) {\n const receiver = connectionContext.messageReceivers[receiverName];\n if (receiver && receiver.receiverType === receiverType) {\n logger.verbose(\n \"[%s] calling detached on %s receiver '%s'.\",\n connectionContext.connection.id,\n receiver.receiverType,\n receiver.name,\n );\n detachCalls.push(\n receiver.onDetached(contextOrConnectionError).catch((err) => {\n logger.logError(\n err,\n \"[%s] An error occurred while calling onDetached() on the %s receiver '%s'\",\n connectionContext.connection.id,\n receiver.receiverType,\n receiver.name,\n );\n }),\n );\n }\n }\n return Promise.all(detachCalls);\n}\n\n/**\n * @internal\n * Helper method to call onDetached on the session receivers from the connection context upon seeing an error.\n */\nasync function callOnDetachedOnSessionReceivers(\n connectionContext: ConnectionContext,\n contextOrConnectionError: Error | ConnectionError | AmqpError | undefined,\n): Promise<void[]> {\n const getSessionError = (sessionId: string, entityPath: string): ServiceBusError => {\n const sessionInfo =\n `The receiver for session \"${sessionId}\" in \"${entityPath}\" has been closed and can no longer be used. ` +\n `Please create a new receiver using the \"acceptSession\" or \"acceptNextSession\" method on the ServiceBusClient.`;\n\n const errorMessage =\n contextOrConnectionError == null\n ? `Unknown error occurred on the AMQP connection while receiving messages. ` + sessionInfo\n : `Error occurred on the AMQP connection while receiving messages. ` +\n sessionInfo +\n `\\nMore info - \\n${contextOrConnectionError}`;\n\n const error = new ServiceBusError(errorMessage, \"SessionLockLost\");\n error.retryable = false;\n return error;\n };\n\n const detachCalls: Promise<void>[] = [];\n\n for (const receiverName of Object.keys(connectionContext.messageSessions)) {\n const receiver = connectionContext.messageSessions[receiverName];\n logger.verbose(\n \"[%s] calling detached on %s receiver(sessions).\",\n connectionContext.connection.id,\n receiver.name,\n );\n detachCalls.push(\n receiver.onDetached(getSessionError(receiver.sessionId, receiver.entityPath)).catch((err) => {\n logger.logError(\n err,\n \"[%s] An error occurred while calling onDetached() on the session receiver(sessions) '%s'\",\n connectionContext.connection.id,\n receiver.name,\n );\n }),\n );\n }\n\n return Promise.all(detachCalls);\n}\n\n/**\n * @internal\n * Helper method to get the number of receivers of specified type from the connectionContext.\n */\nfunction getNumberOfReceivers(\n connectionContext: Pick<ConnectionContext, \"messageReceivers\" | \"messageSessions\">,\n receiverType: ReceiverType,\n): number {\n if (receiverType === \"session\") {\n const receivers = connectionContext.messageSessions;\n return Object.keys(receivers).length;\n }\n const receivers = connectionContext.messageReceivers;\n const receiverNames = Object.keys(receivers);\n const count = receiverNames.reduce(\n (acc, name) => (receivers[name].receiverType === receiverType ? ++acc : acc),\n 0,\n );\n return count;\n}\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ConnectionContext {\n export function create(\n config: ConnectionConfig,\n tokenCredential: SasTokenProvider | TokenCredential,\n options?: ServiceBusClientOptions,\n ): ConnectionContext {\n if (!options) options = {};\n const userAgent = `${formatUserAgentPrefix(\n options.userAgentOptions?.userAgentPrefix,\n )} ${getRuntimeInfo()}`;\n const parameters: CreateConnectionContextBaseParameters = {\n config: config,\n // re-enabling this will be a post-GA discussion similar to event-hubs.\n // dataTransformer: options.dataTransformer,\n isEntityPathRequired: false,\n connectionProperties: {\n product: \"MSJSClient\",\n userAgent,\n version: packageJsonInfo.version,\n },\n };\n // Let us create the base context and then add ServiceBus specific ConnectionContext properties.\n const connectionContext = ConnectionContextBase.create(parameters) as ConnectionContext;\n connectionContext.tokenCredential = tokenCredential;\n connectionContext.senders = {};\n connectionContext.messageReceivers = {};\n connectionContext.messageSessions = {};\n connectionContext.managementClients = {};\n\n let waitForConnectionRefreshResolve: () => void;\n let waitForConnectionRefreshPromise: Promise<void> | undefined;\n Object.assign<ConnectionContext, ConnectionContextMethods>(connectionContext, {\n isConnectionClosing() {\n // When the connection is not open, but the remote end is open,\n // then the rhea connection is in the process of terminating.\n return Boolean(!this.connection.isOpen() && this.connection.isRemoteOpen());\n },\n async readyToOpenLink() {\n logger.verbose(\n `[${this.connectionId}] Waiting until the connection is ready to open link.`,\n );\n // Check that the connection isn't in the process of closing.\n // This can happen when the idle timeout has been reached but\n // the underlying socket is waiting to be destroyed.\n if (this.isConnectionClosing()) {\n logger.verbose(\n `[${this.connectionId}] Connection is closing, waiting for disconnected event`,\n );\n // Wait for the disconnected event that indicates the underlying socket has closed.\n await this.waitForDisconnectedEvent();\n }\n\n // Wait for the connection to be reset.\n await this.waitForConnectionReset();\n logger.verbose(`[${this.connectionId}] Connection is ready to open link.`);\n },\n waitForDisconnectedEvent() {\n return new Promise((resolve) => {\n logger.verbose(\n `[${this.connectionId}] Attempting to reinitialize connection` +\n ` but the connection is in the process of closing.` +\n ` Waiting for the disconnect event before continuing.`,\n );\n this.connection.once(ConnectionEvents.disconnected, resolve);\n });\n },\n waitForConnectionReset() {\n // Check if the connection is currently in the process of disconnecting.\n if (waitForConnectionRefreshPromise) {\n logger.verbose(`[${this.connectionId}] Waiting for connection reset`);\n return waitForConnectionRefreshPromise;\n }\n\n logger.verbose(\n `[${this.connectionId}] Connection not waiting to be reset. Resolving immediately.`,\n );\n return Promise.resolve();\n },\n getReceiverFromCache(\n receiverName: string,\n sessionId?: string,\n ): MessageReceiver | MessageSession | undefined {\n if (sessionId != null && this.messageSessions[receiverName]) {\n return this.messageSessions[receiverName];\n }\n\n if (this.messageReceivers[receiverName]) {\n return this.messageReceivers[receiverName];\n }\n\n let existingReceivers = \"\";\n if (sessionId != null) {\n for (const messageSessionName of Object.keys(this.messageSessions)) {\n if (this.messageSessions[messageSessionName].sessionId === sessionId) {\n existingReceivers = this.messageSessions[messageSessionName].name;\n break;\n }\n }\n } else {\n existingReceivers +=\n (existingReceivers ? \", \" : \"\") + Object.keys(this.messageReceivers).join(\",\");\n }\n\n logger.verbose(\n \"[%s] Failed to find receiver '%s' among existing receivers: %s\",\n this.connectionId,\n receiverName,\n existingReceivers,\n );\n return;\n },\n getManagementClient(entityPath: string): ManagementClient {\n if (!this.managementClients[entityPath]) {\n this.managementClients[entityPath] = new ManagementClient(this, entityPath, {\n address: `${entityPath}/$management`,\n });\n }\n return this.managementClients[entityPath];\n },\n });\n\n // Define listeners to be added to the connection object for\n // \"connection_open\" and \"connection_error\" events.\n const onConnectionOpen: OnAmqpEvent = () => {\n connectionContext.wasConnectionCloseCalled = false;\n logger.verbose(\n \"[%s] setting 'wasConnectionCloseCalled' property of connection context to %s.\",\n connectionContext.connection.id,\n connectionContext.wasConnectionCloseCalled,\n );\n };\n\n const disconnected: OnAmqpEvent = async (context: EventContext) => {\n if (waitForConnectionRefreshPromise) {\n return;\n }\n\n waitForConnectionRefreshPromise = new Promise((resolve) => {\n waitForConnectionRefreshResolve = resolve;\n });\n\n const connectionError =\n context.connection && context.connection.error ? context.connection.error : undefined;\n if (connectionError) {\n logger.logError(\n connectionError,\n \"[%s] Error (context.connection.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n const contextError = context.error;\n if (contextError) {\n logger.logError(\n contextError,\n \"[%s] Error (context.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n const state: Readonly<{\n wasConnectionCloseCalled: boolean;\n numSenders: number;\n numReceivers: number;\n }> = {\n wasConnectionCloseCalled: connectionContext.wasConnectionCloseCalled,\n numSenders: Object.keys(connectionContext.senders).length,\n numReceivers:\n Object.keys(connectionContext.messageReceivers).length +\n Object.keys(connectionContext.messageSessions).length,\n };\n\n // Clear internal map maintained by rhea to avoid reconnecting of old links once the\n // connection is back up.\n connectionContext.connection.removeAllSessions();\n\n // Close the cbs session to ensure all the event handlers are released.\n await connectionContext.cbsSession.close();\n\n // Close the management sessions to ensure all the event handlers are released.\n for (const entityPath of Object.keys(connectionContext.managementClients)) {\n await connectionContext.managementClients[entityPath].close();\n }\n\n if (state.wasConnectionCloseCalled) {\n // Do Nothing\n } else {\n // Calling onDetached on sender\n if (state.numSenders) {\n // We don't do recovery for the sender:\n // Because we don't want to keep the sender active all the time\n // and the \"next\" send call would bear the burden of creating the link.\n // Call onDetached() on sender so that it can gracefully shutdown\n // by cleaning up the timers and closing the links.\n // We don't call onDetached for sender after `refreshConnection()`\n // because any new send calls that potentially initialize links would also get affected if called later.\n logger.verbose(\n `[${connectionContext.connection.id}] connection.close() was not called from the sdk and there were ${state.numSenders} ` +\n `senders. We should not reconnect.`,\n );\n const detachCalls: Promise<void>[] = [];\n for (const senderName of Object.keys(connectionContext.senders)) {\n const sender = connectionContext.senders[senderName];\n if (sender) {\n logger.verbose(\n \"[%s] calling detached on sender '%s'.\",\n connectionContext.connection.id,\n sender.name,\n );\n detachCalls.push(\n sender.onDetached().catch((err) => {\n logger.logError(\n err,\n \"[%s] An error occurred while calling onDetached() the sender '%s'\",\n connectionContext.connection.id,\n sender.name,\n );\n }),\n );\n }\n }\n await Promise.all(detachCalls);\n }\n\n // Calling onDetached on batching receivers for the same reasons as sender\n const numBatchingReceivers = getNumberOfReceivers(connectionContext, \"batching\");\n if (numBatchingReceivers) {\n logger.verbose(\n `[${connectionContext.connection.id}] connection.close() was not called from the sdk and there were ${numBatchingReceivers} ` +\n `batching receivers. We should not reconnect.`,\n );\n\n // Call onDetached() on receivers so that batching receivers it can gracefully close any ongoing batch operation\n await callOnDetachedOnReceivers(\n connectionContext,\n connectionError || contextError,\n \"batching\",\n );\n }\n\n // Calling onDetached on session receivers\n const numSessionReceivers = getNumberOfReceivers(connectionContext, \"session\");\n if (numSessionReceivers) {\n logger.verbose(\n `[${connectionContext.connection.id}] connection.close() was not called from the sdk and there were ${numSessionReceivers} ` +\n `session receivers. We should close them.`,\n );\n\n await callOnDetachedOnSessionReceivers(\n connectionContext,\n connectionError || contextError,\n );\n }\n }\n await refreshConnection();\n waitForConnectionRefreshResolve();\n waitForConnectionRefreshPromise = undefined;\n // The connection should always be brought back up if the sdk did not call connection.close()\n // and there was at least one receiver link on the connection before it went down.\n logger.verbose(\"[%s] state: %O\", connectionContext.connectionId, state);\n\n // Calling onDetached on streaming receivers\n const numStreamingReceivers = getNumberOfReceivers(connectionContext, \"streaming\");\n if (!state.wasConnectionCloseCalled && numStreamingReceivers) {\n logger.verbose(\n `[${connectionContext.connection.id}] connection.close() was not called from the sdk and there were ${numStreamingReceivers} ` +\n `streaming receivers. We should reconnect.`,\n );\n\n // Calling `onDetached()` on streaming receivers after the refreshConnection() since `onDetached()` would\n // recover the streaming receivers and that would only be possible after the connection is refreshed.\n //\n // This is different from the batching receiver since `onDetached()` for the batching receiver would\n // return the outstanding messages and close the receive link.\n await callOnDetachedOnReceivers(\n connectionContext,\n connectionError || contextError,\n \"streaming\",\n );\n }\n };\n\n const protocolError: OnAmqpEvent = async (context: EventContext) => {\n if (context.connection && context.connection.error) {\n logger.logError(\n context.connection.error,\n \"[%s] Error (context.connection.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n if (context.error) {\n logger.logError(\n context.error,\n \"[%s] Error (context.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n };\n\n const error: OnAmqpEvent = async (context: EventContext) => {\n if (context.connection && context.connection.error) {\n logger.logError(\n context.connection.error,\n \"[%s] Error (context.connection.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n if (context.error) {\n logger.logError(\n context.error,\n \"[%s] Error (context.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n };\n\n async function refreshConnection(): Promise<void> {\n const originalConnectionId = connectionContext.connectionId;\n try {\n await cleanConnectionContext();\n } catch (err: any) {\n logger.logError(\n err,\n `[${connectionContext.connectionId}] There was an error closing the connection before reconnecting`,\n );\n }\n // Create a new connection, id, locks, and cbs client.\n connectionContext.refreshConnection();\n addConnectionListeners(connectionContext.connection);\n logger.verbose(\n `The connection \"${originalConnectionId}\" has been updated to \"${connectionContext.connectionId}\".`,\n );\n }\n\n function addConnectionListeners(connection: Connection): void {\n // Add listeners on the connection object.\n connection.on(ConnectionEvents.connectionOpen, onConnectionOpen);\n connection.on(ConnectionEvents.disconnected, disconnected);\n connection.on(ConnectionEvents.protocolError, protocolError);\n connection.on(ConnectionEvents.error, error);\n }\n\n async function cleanConnectionContext(): Promise<void> {\n // Remove listeners from the connection object.\n connectionContext.connection.removeListener(\n ConnectionEvents.connectionOpen,\n onConnectionOpen,\n );\n connectionContext.connection.removeListener(ConnectionEvents.disconnected, disconnected);\n connectionContext.connection.removeListener(ConnectionEvents.protocolError, protocolError);\n connectionContext.connection.removeListener(ConnectionEvents.error, error);\n // Close the connection\n await connectionContext.connection.close();\n }\n\n addConnectionListeners(connectionContext.connection);\n\n logger.verbose(\"[%s] Created connection context successfully.\", connectionContext.connectionId);\n\n return connectionContext;\n }\n\n /**\n * Closes the AMQP connection created by this ServiceBusClient along with AMQP links for\n * sender/receivers created by the queue/topic/subscription clients created by this\n * ServiceBusClient.\n * Once closed,\n * - the clients created by this ServiceBusClient cannot be used to send/receive messages anymore.\n * - this ServiceBusClient cannot be used to create any new queues/topics/subscriptions clients.\n */\n export async function close(context: ConnectionContext): Promise<void> {\n const logPrefix = `[${context.connectionId}]`;\n\n try {\n logger.verbose(`${logPrefix} Permanently closing the amqp connection on the client.`);\n\n const senderNames = Object.keys(context.senders);\n const messageReceiverNames = Object.keys(context.messageReceivers);\n const messageSessionNames = Object.keys(context.messageSessions);\n const managementClientsEntityPaths = Object.keys(context.managementClients);\n logger.verbose(\n `${logPrefix} Permanently closing all the senders(${senderNames.length}), MessageReceivers(${messageReceiverNames.length}), MessageSessions(${messageSessionNames.length}), and ManagementClients(${managementClientsEntityPaths.length}).`,\n );\n await Promise.all([\n ...senderNames.map((n) => context.senders[n].close()),\n ...messageReceiverNames.map((n) => context.messageReceivers[n].close()),\n ...messageSessionNames.map((n) => context.messageSessions[n].close()),\n ...managementClientsEntityPaths.map((p) => context.managementClients[p].close()),\n ]);\n\n logger.verbose(`${logPrefix} Permanently closing cbsSession`);\n await context.cbsSession.close();\n\n logger.verbose(`${logPrefix} Permanently closing internal connection`);\n await context.connection.close();\n context.wasConnectionCloseCalled = true;\n logger.verbose(`[${logPrefix} Permanently closed the amqp connection on the client.`);\n } catch (err: any) {\n const errObj = err instanceof Error ? err : new Error(JSON.stringify(err));\n logger.logError(err, `${logPrefix} An error occurred while closing the conn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aACjF,CAAC,CAAC;YAEH,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,iCAAiC,CAAC,CAAC;YAC9D,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YAEjC,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,0CAA0C,CAAC,CAAC;YACvE,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACjC,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;YACxC,MAAM,CAAC,OAAO,CAAC,IAAI,SAAS,wDAAwD,CAAC,CAAC;QACxF,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3E,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,SAAS,iDAAiD,CAAC,CAAC;YACpF,MAAM,MAAM,CAAC;QACf,CAAC;IACH,CAAC;IAhCqB,uBAAK,QAgC1B,CAAA;AACH,CAAC,EAjZgB,iBAAiB,KAAjB,iBAAiB,QAiZjC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { connectionLogger as logger } from \"./log.js\";\nimport { packageJsonInfo } from \"./util/constants.js\";\nimport type {\n ConnectionConfig,\n CreateConnectionContextBaseParameters,\n SasTokenProvider,\n} from \"@azure/core-amqp\";\nimport { ConnectionContextBase } from \"@azure/core-amqp\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { ServiceBusClientOptions } from \"./constructorHelpers.js\";\nimport type {\n AmqpError,\n Connection,\n ConnectionError,\n EventContext,\n OnAmqpEvent,\n} from \"rhea-promise\";\nimport { ConnectionEvents } from \"rhea-promise\";\nimport type { MessageSender } from \"./core/messageSender.js\";\nimport type { MessageSession } from \"./session/messageSession.js\";\nimport type { MessageReceiver } from \"./core/messageReceiver.js\";\nimport { ManagementClient } from \"./core/managementClient.js\";\nimport { formatUserAgentPrefix } from \"./util/utils.js\";\nimport { getRuntimeInfo } from \"./util/runtimeInfo.js\";\nimport type { NonSessionReceiverType, ReceiverType } from \"./core/linkEntity.js\";\nimport { ServiceBusError } from \"./serviceBusError.js\";\n\n/**\n * @internal\n * Provides contextual information like the underlying amqp connection, cbs session, management session,\n * tokenCredential, senders, receivers, etc. about the ServiceBus client.\n */\nexport interface ConnectionContext extends ConnectionContextBase {\n /**\n * The credential to be used for Authentication.\n * Default value: SasTokenProvider.\n */\n tokenCredential: SasTokenProvider | TokenCredential;\n /**\n * A map of active Service Bus Senders with sender name as key.\n */\n senders: { [name: string]: MessageSender };\n /**\n * A map of active Service Bus receivers for non session enabled queues/subscriptions\n * with receiver name as key.\n */\n messageReceivers: { [name: string]: MessageReceiver };\n /**\n * A map of active Service Bus receivers for session enabled queues/subscriptions\n * with receiver name as key.\n */\n messageSessions: { [name: string]: MessageSession };\n /**\n * A map of ManagementClient instances for operations over the $management link\n * with key as the entity path.\n */\n managementClients: { [name: string]: ManagementClient };\n /**\n * Function returning a promise that resolves once the connectionContext is ready to open an AMQP link.\n * ConnectionContext will be ready to open an AMQP link when:\n * - The AMQP connection is already open on both sides.\n * - The AMQP connection has been closed or disconnected. In this case, a new AMQP connection is expected\n * to be created first.\n * An AMQP link cannot be opened if the AMQP connection\n * is in the process of closing or disconnecting.\n */\n readyToOpenLink(): Promise<void>;\n /**\n * Fetches the receiver from the cache in ConnectionContext based on the receiverName given.\n * Useful for when a message needs to be settled or have its lock renewed.\n *\n * TODO: Track the right receiver on the message instead of the ConnectionContext to remove\n * the need for this helper.\n */\n getReceiverFromCache(\n receiverName: string,\n sessionId?: string,\n ): MessageReceiver | MessageSession | undefined;\n /**\n * Gets the management client for given entity path from the cache\n * Creates one if none exists in the cache\n */\n getManagementClient(entityPath: string): ManagementClient;\n /**\n * Indicates whether the connection is in the process of closing.\n * When this returns `true`, a `disconnected` event will be received\n * after the connection is closed.\n */\n isConnectionClosing(): boolean;\n}\n\n/**\n * Describes the members on the ConnectionContext that are only\n * used by it internally.\n * @hidden\n * @internal\n */\nexport interface ConnectionContextInternalMembers extends ConnectionContext {\n /**\n * Resolves once the context's connection emits a `disconnected` event.\n */\n waitForDisconnectedEvent(): Promise<void>;\n /**\n * Resolves once the connection has finished being reset.\n * Connections are reset as part of reacting to a `disconnected` event.\n */\n waitForConnectionReset(): Promise<void>;\n}\n\n/**\n * @internal\n * Helper type to get the names of all the functions on an object.\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\ntype FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];\n/**\n * @internal\n * Helper type to get the types of all the functions on an object.\n */\ntype FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;\n/**\n * @internal\n * Helper type to get the types of all the functions on ConnectionContext\n * and the internal methods from ConnectionContextInternalMembers.\n * Note that this excludes the functions that ConnectionContext inherits.\n * Each function also has its `this` type set as `ConnectionContext`.\n */\ntype ConnectionContextMethods = Omit<\n FunctionProperties<ConnectionContextInternalMembers>,\n FunctionPropertyNames<ConnectionContextBase>\n> &\n ThisType<ConnectionContextInternalMembers>;\n\n/**\n * @internal\n * Helper method to call onDetached on the non-sessions batching and streaming receivers from the connection context upon seeing an error.\n */\nasync function callOnDetachedOnReceivers(\n connectionContext: ConnectionContext,\n contextOrConnectionError: Error | ConnectionError | AmqpError | undefined,\n receiverType: NonSessionReceiverType,\n): Promise<void[]> {\n const detachCalls: Promise<void>[] = [];\n\n // Iterating over non-sessions batching and streaming receivers\n for (const receiverName of Object.keys(connectionContext.messageReceivers)) {\n const receiver = connectionContext.messageReceivers[receiverName];\n if (receiver && receiver.receiverType === receiverType) {\n logger.verbose(\n \"[%s] calling detached on %s receiver '%s'.\",\n connectionContext.connection.id,\n receiver.receiverType,\n receiver.name,\n );\n detachCalls.push(\n receiver.onDetached(contextOrConnectionError).catch((err) => {\n logger.logError(\n err,\n \"[%s] An error occurred while calling onDetached() on the %s receiver '%s'\",\n connectionContext.connection.id,\n receiver.receiverType,\n receiver.name,\n );\n }),\n );\n }\n }\n return Promise.all(detachCalls);\n}\n\n/**\n * @internal\n * Helper method to call onDetached on the session receivers from the connection context upon seeing an error.\n */\nasync function callOnDetachedOnSessionReceivers(\n connectionContext: ConnectionContext,\n contextOrConnectionError: Error | ConnectionError | AmqpError | undefined,\n): Promise<void[]> {\n const getSessionError = (sessionId: string, entityPath: string): ServiceBusError => {\n const sessionInfo =\n `The receiver for session \"${sessionId}\" in \"${entityPath}\" has been closed and can no longer be used. ` +\n `Please create a new receiver using the \"acceptSession\" or \"acceptNextSession\" method on the ServiceBusClient.`;\n\n const errorMessage =\n contextOrConnectionError == null\n ? `Unknown error occurred on the AMQP connection while receiving messages. ` + sessionInfo\n : `Error occurred on the AMQP connection while receiving messages. ` +\n sessionInfo +\n `\\nMore info - \\n${contextOrConnectionError}`;\n\n const error = new ServiceBusError(errorMessage, \"SessionLockLost\");\n error.retryable = false;\n return error;\n };\n\n const detachCalls: Promise<void>[] = [];\n\n for (const receiverName of Object.keys(connectionContext.messageSessions)) {\n const receiver = connectionContext.messageSessions[receiverName];\n logger.verbose(\n \"[%s] calling detached on %s receiver(sessions).\",\n connectionContext.connection.id,\n receiver.name,\n );\n detachCalls.push(\n receiver.onDetached(getSessionError(receiver.sessionId, receiver.entityPath)).catch((err) => {\n logger.logError(\n err,\n \"[%s] An error occurred while calling onDetached() on the session receiver(sessions) '%s'\",\n connectionContext.connection.id,\n receiver.name,\n );\n }),\n );\n }\n\n return Promise.all(detachCalls);\n}\n\n/**\n * @internal\n * Helper method to get the number of receivers of specified type from the connectionContext.\n */\nfunction getNumberOfReceivers(\n connectionContext: Pick<ConnectionContext, \"messageReceivers\" | \"messageSessions\">,\n receiverType: ReceiverType,\n): number {\n if (receiverType === \"session\") {\n const receivers = connectionContext.messageSessions;\n return Object.keys(receivers).length;\n }\n const receivers = connectionContext.messageReceivers;\n const receiverNames = Object.keys(receivers);\n const count = receiverNames.reduce(\n (acc, name) => (receivers[name].receiverType === receiverType ? ++acc : acc),\n 0,\n );\n return count;\n}\n\n/**\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ConnectionContext {\n export function create(\n config: ConnectionConfig,\n tokenCredential: SasTokenProvider | TokenCredential,\n options?: ServiceBusClientOptions,\n ): ConnectionContext {\n if (!options) options = {};\n const userAgent = `${formatUserAgentPrefix(\n options.userAgentOptions?.userAgentPrefix,\n )} ${getRuntimeInfo()}`;\n const parameters: CreateConnectionContextBaseParameters = {\n config: config,\n // re-enabling this will be a post-GA discussion similar to event-hubs.\n // dataTransformer: options.dataTransformer,\n isEntityPathRequired: false,\n connectionProperties: {\n product: \"MSJSClient\",\n userAgent,\n version: packageJsonInfo.version,\n },\n };\n // Let us create the base context and then add ServiceBus specific ConnectionContext properties.\n const connectionContext = ConnectionContextBase.create(parameters) as ConnectionContext;\n connectionContext.tokenCredential = tokenCredential;\n connectionContext.senders = {};\n connectionContext.messageReceivers = {};\n connectionContext.messageSessions = {};\n connectionContext.managementClients = {};\n\n let waitForConnectionRefreshResolve: () => void;\n let waitForConnectionRefreshPromise: Promise<void> | undefined;\n Object.assign<ConnectionContext, ConnectionContextMethods>(connectionContext, {\n isConnectionClosing() {\n // When the connection is not open, but the remote end is open,\n // then the rhea connection is in the process of terminating.\n return Boolean(!this.connection.isOpen() && this.connection.isRemoteOpen());\n },\n async readyToOpenLink() {\n logger.verbose(\n `[${this.connectionId}] Waiting until the connection is ready to open link.`,\n );\n // Check that the connection isn't in the process of closing.\n // This can happen when the idle timeout has been reached but\n // the underlying socket is waiting to be destroyed.\n if (this.isConnectionClosing()) {\n logger.verbose(\n `[${this.connectionId}] Connection is closing, waiting for disconnected event`,\n );\n // Wait for the disconnected event that indicates the underlying socket has closed.\n await this.waitForDisconnectedEvent();\n }\n\n // Wait for the connection to be reset.\n await this.waitForConnectionReset();\n logger.verbose(`[${this.connectionId}] Connection is ready to open link.`);\n },\n waitForDisconnectedEvent() {\n return new Promise((resolve) => {\n logger.verbose(\n `[${this.connectionId}] Attempting to reinitialize connection` +\n ` but the connection is in the process of closing.` +\n ` Waiting for the disconnect event before continuing.`,\n );\n this.connection.once(ConnectionEvents.disconnected, resolve);\n });\n },\n waitForConnectionReset() {\n // Check if the connection is currently in the process of disconnecting.\n if (waitForConnectionRefreshPromise) {\n logger.verbose(`[${this.connectionId}] Waiting for connection reset`);\n return waitForConnectionRefreshPromise;\n }\n\n logger.verbose(\n `[${this.connectionId}] Connection not waiting to be reset. Resolving immediately.`,\n );\n return Promise.resolve();\n },\n getReceiverFromCache(\n receiverName: string,\n sessionId?: string,\n ): MessageReceiver | MessageSession | undefined {\n if (sessionId != null && this.messageSessions[receiverName]) {\n return this.messageSessions[receiverName];\n }\n\n if (this.messageReceivers[receiverName]) {\n return this.messageReceivers[receiverName];\n }\n\n let existingReceivers = \"\";\n if (sessionId != null) {\n for (const messageSessionName of Object.keys(this.messageSessions)) {\n if (this.messageSessions[messageSessionName].sessionId === sessionId) {\n existingReceivers = this.messageSessions[messageSessionName].name;\n break;\n }\n }\n } else {\n existingReceivers +=\n (existingReceivers ? \", \" : \"\") + Object.keys(this.messageReceivers).join(\",\");\n }\n\n logger.verbose(\n \"[%s] Failed to find receiver '%s' among existing receivers: %s\",\n this.connectionId,\n receiverName,\n existingReceivers,\n );\n return;\n },\n getManagementClient(entityPath: string): ManagementClient {\n if (!this.managementClients[entityPath]) {\n this.managementClients[entityPath] = new ManagementClient(this, entityPath, {\n address: `${entityPath}/$management`,\n });\n }\n return this.managementClients[entityPath];\n },\n });\n\n // Define listeners to be added to the connection object for\n // \"connection_open\" and \"connection_error\" events.\n const onConnectionOpen: OnAmqpEvent = () => {\n connectionContext.wasConnectionCloseCalled = false;\n logger.verbose(\n \"[%s] setting 'wasConnectionCloseCalled' property of connection context to %s.\",\n connectionContext.connection.id,\n connectionContext.wasConnectionCloseCalled,\n );\n };\n\n const disconnected: OnAmqpEvent = async (context: EventContext) => {\n if (waitForConnectionRefreshPromise) {\n return;\n }\n\n waitForConnectionRefreshPromise = new Promise((resolve) => {\n waitForConnectionRefreshResolve = resolve;\n });\n\n const connectionError =\n context.connection && context.connection.error ? context.connection.error : undefined;\n if (connectionError) {\n logger.logError(\n connectionError,\n \"[%s] Error (context.connection.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n const contextError = context.error;\n if (contextError) {\n logger.logError(\n contextError,\n \"[%s] Error (context.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n const state: Readonly<{\n wasConnectionCloseCalled: boolean;\n numSenders: number;\n numReceivers: number;\n }> = {\n wasConnectionCloseCalled: connectionContext.wasConnectionCloseCalled,\n numSenders: Object.keys(connectionContext.senders).length,\n numReceivers:\n Object.keys(connectionContext.messageReceivers).length +\n Object.keys(connectionContext.messageSessions).length,\n };\n\n // Clear internal map maintained by rhea to avoid reconnecting of old links once the\n // connection is back up.\n connectionContext.connection.removeAllSessions();\n\n // Close the cbs session to ensure all the event handlers are released.\n await connectionContext.cbsSession.close();\n\n // Close the management sessions to ensure all the event handlers are released.\n for (const entityPath of Object.keys(connectionContext.managementClients)) {\n await connectionContext.managementClients[entityPath].close();\n }\n\n if (state.wasConnectionCloseCalled) {\n // Do Nothing\n } else {\n // Calling onDetached on sender\n if (state.numSenders) {\n // We don't do recovery for the sender:\n // Because we don't want to keep the sender active all the time\n // and the \"next\" send call would bear the burden of creating the link.\n // Call onDetached() on sender so that it can gracefully shutdown\n // by cleaning up the timers and closing the links.\n // We don't call onDetached for sender after `refreshConnection()`\n // because any new send calls that potentially initialize links would also get affected if called later.\n logger.verbose(\n `[${connectionContext.connection.id}] connection.close() was not called from the sdk and there were ${state.numSenders} ` +\n `senders. We should not reconnect.`,\n );\n const detachCalls: Promise<void>[] = [];\n for (const senderName of Object.keys(connectionContext.senders)) {\n const sender = connectionContext.senders[senderName];\n if (sender) {\n logger.verbose(\n \"[%s] calling detached on sender '%s'.\",\n connectionContext.connection.id,\n sender.name,\n );\n detachCalls.push(\n sender.onDetached().catch((err) => {\n logger.logError(\n err,\n \"[%s] An error occurred while calling onDetached() the sender '%s'\",\n connectionContext.connection.id,\n sender.name,\n );\n }),\n );\n }\n }\n await Promise.all(detachCalls);\n }\n\n // Calling onDetached on batching receivers for the same reasons as sender\n const numBatchingReceivers = getNumberOfReceivers(connectionContext, \"batching\");\n if (numBatchingReceivers) {\n logger.verbose(\n `[${connectionContext.connection.id}] connection.close() was not called from the sdk and there were ${numBatchingReceivers} ` +\n `batching receivers. We should not reconnect.`,\n );\n\n // Call onDetached() on receivers so that batching receivers it can gracefully close any ongoing batch operation\n await callOnDetachedOnReceivers(\n connectionContext,\n connectionError || contextError,\n \"batching\",\n );\n }\n\n // Calling onDetached on session receivers\n const numSessionReceivers = getNumberOfReceivers(connectionContext, \"session\");\n if (numSessionReceivers) {\n logger.verbose(\n `[${connectionContext.connection.id}] connection.close() was not called from the sdk and there were ${numSessionReceivers} ` +\n `session receivers. We should close them.`,\n );\n\n await callOnDetachedOnSessionReceivers(\n connectionContext,\n connectionError || contextError,\n );\n }\n }\n await refreshConnection();\n waitForConnectionRefreshResolve();\n waitForConnectionRefreshPromise = undefined;\n // The connection should always be brought back up if the sdk did not call connection.close()\n // and there was at least one receiver link on the connection before it went down.\n logger.verbose(\"[%s] state: %O\", connectionContext.connectionId, state);\n\n // Calling onDetached on streaming receivers\n const numStreamingReceivers = getNumberOfReceivers(connectionContext, \"streaming\");\n if (!state.wasConnectionCloseCalled && numStreamingReceivers) {\n logger.verbose(\n `[${connectionContext.connection.id}] connection.close() was not called from the sdk and there were ${numStreamingReceivers} ` +\n `streaming receivers. We should reconnect.`,\n );\n\n // Calling `onDetached()` on streaming receivers after the refreshConnection() since `onDetached()` would\n // recover the streaming receivers and that would only be possible after the connection is refreshed.\n //\n // This is different from the batching receiver since `onDetached()` for the batching receiver would\n // return the outstanding messages and close the receive link.\n await callOnDetachedOnReceivers(\n connectionContext,\n connectionError || contextError,\n \"streaming\",\n );\n }\n };\n\n const protocolError: OnAmqpEvent = async (context: EventContext) => {\n if (context.connection && context.connection.error) {\n logger.logError(\n context.connection.error,\n \"[%s] Error (context.connection.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n if (context.error) {\n logger.logError(\n context.error,\n \"[%s] Error (context.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n };\n\n const error: OnAmqpEvent = async (context: EventContext) => {\n if (context.connection && context.connection.error) {\n logger.logError(\n context.connection.error,\n \"[%s] Error (context.connection.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n if (context.error) {\n logger.logError(\n context.error,\n \"[%s] Error (context.error) occurred on the amqp connection\",\n connectionContext.connection.id,\n );\n }\n };\n\n async function refreshConnection(): Promise<void> {\n const originalConnectionId = connectionContext.connectionId;\n try {\n await cleanConnectionContext();\n } catch (err: any) {\n logger.logError(\n err,\n `[${connectionContext.connectionId}] There was an error closing the connection before reconnecting`,\n );\n }\n // Create a new connection, id, locks, and cbs client.\n connectionContext.refreshConnection();\n addConnectionListeners(connectionContext.connection);\n logger.verbose(\n `The connection \"${originalConnectionId}\" has been updated to \"${connectionContext.connectionId}\".`,\n );\n }\n\n function addConnectionListeners(connection: Connection): void {\n // Add listeners on the connection object.\n connection.on(ConnectionEvents.connectionOpen, onConnectionOpen);\n connection.on(ConnectionEvents.disconnected, disconnected);\n connection.on(ConnectionEvents.protocolError, protocolError);\n connection.on(ConnectionEvents.error, error);\n }\n\n async function cleanConnectionContext(): Promise<void> {\n // Remove listeners from the connection object.\n connectionContext.connection.removeListener(\n ConnectionEvents.connectionOpen,\n onConnectionOpen,\n );\n connectionContext.connection.removeListener(ConnectionEvents.disconnected, disconnected);\n connectionContext.connection.removeListener(ConnectionEvents.protocolError, protocolError);\n connectionContext.connection.removeListener(ConnectionEvents.error, error);\n // Close the connection\n await connectionContext.connection.close();\n }\n\n addConnectionListeners(connectionContext.connection);\n\n logger.verbose(\"[%s] Created connection context successfully.\", connectionContext.connectionId);\n\n return connectionContext;\n }\n\n /**\n * Closes the AMQP connection created by this ServiceBusClient along with AMQP links for\n * sender/receivers created by the queue/topic/subscription clients created by this\n * ServiceBusClient.\n * Once closed,\n * - the clients created by this ServiceBusClient cannot be used to send/receive messages anymore.\n * - this ServiceBusClient cannot be used to create any new queues/topics/subscriptions clients.\n */\n export async function close(context: ConnectionContext): Promise<void> {\n const logPrefix = `[${context.connectionId}]`;\n\n try {\n logger.verbose(`${logPrefix} Permanently closing the amqp connection on the client.`);\n\n const senderNames = Object.keys(context.senders);\n const messageReceiverNames = Object.keys(context.messageReceivers);\n const messageSessionNames = Object.keys(context.messageSessions);\n const managementClientsEntityPaths = Object.keys(context.managementClients);\n logger.verbose(\n `${logPrefix} Permanently closing all the senders(${senderNames.length}), MessageReceivers(${messageReceiverNames.length}), MessageSessions(${messageSessionNames.length}), and ManagementClients(${managementClientsEntityPaths.length}).`,\n );\n await Promise.all([\n ...senderNames.map((n) => context.senders[n].close()),\n ...messageReceiverNames.map((n) => context.messageReceivers[n].close()),\n ...messageSessionNames.map((n) => context.messageSessions[n].close()),\n ...managementClientsEntityPaths.map((p) => context.managementClients[p].close()),\n ]);\n\n logger.verbose(`${logPrefix} Permanently closing cbsSession`);\n await context.cbsSession.close();\n\n logger.verbose(`${logPrefix} Permanently closing internal connection`);\n await context.connection.close();\n context.wasConnectionCloseCalled = true;\n logger.verbose(`[${logPrefix} Permanently closed the amqp connection on the client.`);\n } catch (err: any) {\n const errObj = err instanceof Error ? err : new Error(JSON.stringify(err));\n logger.logError(err, `${logPrefix} An error occurred while closing the connection`);\n throw errObj;\n }\n }\n}\n"]}
|
|
@@ -40,12 +40,11 @@ function setCustomEndpointAddress(config, customEndpointAddress) {
|
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
42
|
export function createConnectionContext(connectionString, credential, options) {
|
|
43
|
-
var _a, _b;
|
|
44
43
|
const config = ConnectionConfig.create(connectionString);
|
|
45
|
-
config.webSocket =
|
|
44
|
+
config.webSocket = options?.webSocketOptions?.webSocket;
|
|
46
45
|
config.webSocketEndpointPath = "$servicebus/websocket";
|
|
47
|
-
config.webSocketConstructorOptions =
|
|
48
|
-
if (options
|
|
46
|
+
config.webSocketConstructorOptions = options?.webSocketOptions?.webSocketConstructorOptions;
|
|
47
|
+
if (options?.customEndpointAddress) {
|
|
49
48
|
setCustomEndpointAddress(config, options.customEndpointAddress);
|
|
50
49
|
}
|
|
51
50
|
return ConnectionContext.create(config, credential, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constructorHelpers.js","sourceRoot":"","sources":["../../src/constructorHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,iCAAiC,CAAC;AA+ClF,0EAA0E;AAC1E,+EAA+E;AAC/E;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC5C,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACnD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,SAAS,CAAC,kCAAkC,QAAQ,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3B,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAClC,CAAC;AACD;;;;GAIG;AACH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CAAC,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oCAAoC,CAClD,UAAgE,EAChE,IAAY,EACZ,UAAmC,EAAE;IAErC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,aAAiD,CAAC;IAEtD,6DAA6D;IAC7D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,IAAI,IAAI,GAAG,CAAC;IACd,CAAC;IACD,IAAI,oBAAoB,CAAC,UAAU,CAAC,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QACpE,aAAa,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACN,aAAa,GAAG,UAAU,CAAC;IAC7B,CAAC;IACD,MAAM,gBAAgB,GAAG,iBAAiB,IAAI,sEAAsE,CAAC;IACrH,OAAO,uBAAuB,CAAC,gBAAgB,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAAC,gBAAwB;IACxE,MAAM,eAAe,GAAG,gBAAgB,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAE7E,IAAI,eAAe,IAAI,IAAI,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5D,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RetryOptions, SasTokenProvider, WebSocketOptions } from \"@azure/core-amqp\";\nimport { ConnectionConfig, createSasTokenProvider } from \"@azure/core-amqp\";\nimport type { NamedKeyCredential, SASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isNamedKeyCredential, isSASCredential } from \"@azure/core-auth\";\nimport { ConnectionContext } from \"./connectionContext.js\";\nimport type { UserAgentPolicyOptions } from \"@azure/core-rest-pipeline\";\nimport type { ServiceBusConnectionStringProperties } from \"./util/connectionStringUtils.js\";\nimport { parseServiceBusConnectionString } from \"./util/connectionStringUtils.js\";\n\n/**\n * Describes the options that can be provided while creating the ServiceBusClient.\n *\n * - `webSocketOptions` : Options to configure the channelling of the AMQP connection over Web Sockets.\n * - `websocket` : The WebSocket constructor used to create an AMQP connection if you choose to make the connection\n * over a WebSocket.\n * - `webSocketConstructorOptions` : Options to pass to the Websocket constructor when you choose to make the connection\n * over a WebSocket.\n * - `retryOptions` : The retry options for all the operations on the client.\n * - `maxRetries` : The number of times the operation can be retried in case of a retryable error.\n * - `maxRetryDelayInMs`: The maximum delay between retries. Applicable only when performing exponential retries.\n * - `mode`: Which retry mode to apply, specified by the `RetryMode` enum. Options are `Exponential` and `Fixed`. Defaults to `Fixed`.\n * - `retryDelayInMs`: Amount of time to wait in milliseconds before making the next attempt. When `mode` is set to `Exponential`,\n * this is used to compute the exponentially increasing delays between retries. Default: 30000 milliseconds.\n * - `timeoutInMs`: Amount of time in milliseconds to wait before the operation times out. This will trigger a retry if there are any\n * retry attempts remaining. Minimum value: 60000 milliseconds.\n */\nexport interface ServiceBusClientOptions {\n /**\n * ID to identify this client. This can be used to correlate logs and exceptions.\n */\n identifier?: string;\n /**\n * A custom endpoint to use when connecting to the Service Bus service.\n * This can be useful when your network does not allow connecting to the\n * standard Azure Service Bus endpoint address, but does allow connecting\n * through an intermediary.\n *\n * Example: \"https://my.custom.endpoint:100/\"\n */\n customEndpointAddress?: string;\n /**\n * Retry policy options that determine the mode, number of retries, retry interval etc.\n */\n retryOptions?: RetryOptions;\n /**\n * Options to configure the channelling of the AMQP connection over Web Sockets.\n */\n webSocketOptions?: WebSocketOptions;\n /**\n * Options for adding user agent details to outgoing requests.\n */\n userAgentOptions?: UserAgentPolicyOptions;\n}\n\n// TODO: extract parseEndpoint and setCustomEndpointAddress into core-amqp\n// ConnectionConfig so that it can be shared between Event Hubs and Service Bus\n/**\n * Parses the host, hostname, and port from an endpoint.\n * @param endpoint - And endpoint to parse.\n * @internal\n */\nexport function parseEndpoint(endpoint: string): { host: string; hostname: string; port?: string } {\n const hostMatch = endpoint.match(/.*:\\/\\/([^/]*)/);\n if (!hostMatch) {\n throw new TypeError(`Invalid endpoint missing host: ${endpoint}`);\n }\n\n const [, host] = hostMatch;\n const [hostname, port] = host.split(\":\");\n\n return { host, hostname, port };\n}\n/**\n * Updates the provided ConnectionConfig to use the custom endpoint address.\n * @param config - An existing connection configuration to be updated.\n * @param customEndpointAddress - The custom endpoint address to use.\n */\nfunction setCustomEndpointAddress(config: ConnectionConfig, customEndpointAddress: string): void {\n // The amqpHostname should match the host prior to using the custom endpoint.\n config.amqpHostname = config.host;\n const { hostname, port } = parseEndpoint(customEndpointAddress);\n // Since we specify the port separately, set host to the customEndpointAddress hostname.\n config.host = hostname;\n if (port) {\n config.port = parseInt(port, 10);\n }\n}\n\n/**\n * @internal\n *\n */\nexport function createConnectionContext(\n connectionString: string,\n credential: SasTokenProvider | TokenCredential,\n options: ServiceBusClientOptions,\n): ConnectionContext {\n const config = ConnectionConfig.create(connectionString);\n\n config.webSocket = options?.webSocketOptions?.webSocket;\n config.webSocketEndpointPath = \"$servicebus/websocket\";\n config.webSocketConstructorOptions = options?.webSocketOptions?.webSocketConstructorOptions;\n\n if (options?.customEndpointAddress) {\n setCustomEndpointAddress(config, options.customEndpointAddress);\n }\n\n return ConnectionContext.create(config, credential, options);\n}\n\n/**\n * @internal\n */\nexport function createConnectionContextForConnectionString(\n connectionString: string,\n options: ServiceBusClientOptions = {},\n): ConnectionContext {\n const parsed = parseServiceBusConnectionString(connectionString) as Required<\n | Pick<ServiceBusConnectionStringProperties, \"sharedAccessKey\" | \"sharedAccessKeyName\">\n | Pick<ServiceBusConnectionStringProperties, \"sharedAccessSignature\">\n >;\n const sasTokenProvider = createSasTokenProvider(parsed);\n return createConnectionContext(connectionString, sasTokenProvider, options);\n}\n\n/**\n *\n * @internal\n */\nexport function createConnectionContextForCredential(\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n host: string,\n options: ServiceBusClientOptions = {},\n): ConnectionContext {\n if (typeof host !== \"string\") {\n throw new TypeError(\"`host` parameter is not a string\");\n }\n\n let tokenProvider: TokenCredential | SasTokenProvider;\n\n // host, credential and options based constructor was invoked\n if (!host.endsWith(\"/\")) {\n host += \"/\";\n }\n if (isNamedKeyCredential(credential) || isSASCredential(credential)) {\n tokenProvider = createSasTokenProvider(credential);\n } else {\n tokenProvider = credential;\n }\n const connectionString = `Endpoint=sb://${host};SharedAccessKeyName=defaultKeyName;SharedAccessKey=defaultKeyValue;`;\n return createConnectionContext(connectionString, tokenProvider, options);\n}\n\n/**\n * Parses a connection string and extracts the EntityPath named entity out.\n * @param connectionString - An entity specific Service Bus connection string.\n * @internal\n */\nexport function getEntityNameFromConnectionString(connectionString: string): string {\n const entityPathMatch = connectionString.match(/^.+EntityPath=(.+?);{0,1}$/);\n\n if (entityPathMatch != null && entityPathMatch.length === 2) {\n return entityPathMatch[1];\n } else {\n throw new Error(\"No entity name present in the connection string\");\n }\n}\n"]}
|
|
@@ -8,14 +8,18 @@ import { calculateRenewAfterDuration } from "../util/utils.js";
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export class LockRenewer {
|
|
11
|
+
_context;
|
|
12
|
+
_maxAutoRenewDurationInMs;
|
|
13
|
+
/**
|
|
14
|
+
* A map of link names to individual maps for each
|
|
15
|
+
* link that map a message ID to its auto-renewal timer.
|
|
16
|
+
*/
|
|
17
|
+
_messageRenewLockTimers = new Map();
|
|
18
|
+
// just here for make unit testing a bit easier.
|
|
19
|
+
_calculateRenewAfterDuration;
|
|
11
20
|
constructor(_context, _maxAutoRenewDurationInMs) {
|
|
12
21
|
this._context = _context;
|
|
13
22
|
this._maxAutoRenewDurationInMs = _maxAutoRenewDurationInMs;
|
|
14
|
-
/**
|
|
15
|
-
* A map of link names to individual maps for each
|
|
16
|
-
* link that map a message ID to its auto-renewal timer.
|
|
17
|
-
*/
|
|
18
|
-
this._messageRenewLockTimers = new Map();
|
|
19
23
|
this._calculateRenewAfterDuration = calculateRenewAfterDuration;
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoLockRenewer.js","sourceRoot":"","sources":["../../../src/core/autoLockRenewer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAkB/D;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAUtB,YACU,QAAwD,EACxD,yBAAiC;QADjC,aAAQ,GAAR,QAAQ,CAAgD;QACxD,8BAAyB,GAAzB,yBAAyB,CAAQ;QAX3C;;;WAGG;QACK,4BAAuB,GAAG,IAAI,GAAG,EAAmD,CAAC;QAS3F,IAAI,CAAC,4BAA4B,GAAG,2BAA2B,CAAC;IAClE,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,CACX,OAAuD,EACvD,4BAAoC,EACpC,WAA4C;QAE5C,IAAI,WAAW,KAAK,UAAU,EAAE,CAAC;YAC/B,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,4BAA4B,IAAI,CAAC,EAAE,CAAC;YACtC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,UAAuB;QAC7B,MAAM,CAAC,OAAO,CACZ,GAAG,UAAU,CAAC,SAAS,kEAAkE,CAC1F,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GAAG,CAAC,QAAQ,CAAC,SAAmB,EAAE,cAAc,CAAC,CAAC;oBACnE,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,OAAO,CACZ,GAAG,SAAS,0FAA0F,QAAQ,CAAC,SAAS,IAAI,CAC7H,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;YAEF,QAAQ;YACR,iBAAiB,EAAE,CAAC;QACtB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAEO,sBAAsB,CAAC,UAAuB;QACpD,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACvD,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAC9B,UAAU,CAAC,IAAI,EACf,IAAI,GAAG,EAAsC,CAC9C,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAE,CAAC;IAC5D,CAAC;IAEO,kBAAkB,CACxB,UAAuB,EACvB,cAAuD,EACvD,SAA6B;QAE7B,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QAED,sFAAsF;QACtF,WAAW;QACX,IAAI,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAmB,CAAC,CAAC;YAC9D,MAAM,CAAC,OAAO,CACZ,GAAG,UAAU,CAAC,SAAS,8DAA8D,SAAS,IAAI,CACnG,CAAC;YACF,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectionContext } from \"../connectionContext.js\";\nimport { receiverLogger as logger } from \"../log.js\";\nimport type { ServiceBusMessageImpl } from \"../serviceBusMessage.js\";\nimport { calculateRenewAfterDuration } from \"../util/utils.js\";\nimport type { LinkEntity } from \"./linkEntity.js\";\nimport type { OnErrorNoContext } from \"./messageReceiver.js\";\n\n/**\n * @internal\n */\nexport type RenewableMessageProperties = Readonly<\n Pick<ServiceBusMessageImpl, \"lockToken\" | \"messageId\">\n> &\n // updated when we renew the lock\n Pick<ServiceBusMessageImpl, \"lockedUntilUtc\">;\n\n/**\n * @internal\n */\ntype MinimalLink = Pick<LinkEntity<any>, \"name\" | \"logPrefix\" | \"entityPath\">;\n\n/**\n * Tracks locks for messages, renewing until a configurable duration.\n *\n * @internal\n */\nexport class LockRenewer {\n /**\n * A map of link names to individual maps for each\n * link that map a message ID to its auto-renewal timer.\n */\n private _messageRenewLockTimers = new Map<string, Map<string, NodeJS.Timeout | undefined>>();\n\n // just here for make unit testing a bit easier.\n private _calculateRenewAfterDuration: typeof calculateRenewAfterDuration;\n\n constructor(\n private _context: Pick<ConnectionContext, \"getManagementClient\">,\n private _maxAutoRenewDurationInMs: number,\n ) {\n this._calculateRenewAfterDuration = calculateRenewAfterDuration;\n }\n\n /**\n * Creates an AutoLockRenewer.\n *\n * @param linkEntity - Your link entity instance (probably 'this')\n * @param context - The connection context for your link entity (probably 'this._context')\n * @param options - The ReceiveOptions passed through to your message receiver.\n * @returns if the lock mode is peek lock (or if is unspecified, thus defaulting to peekLock)\n * and the options.maxAutoLockRenewalDurationInMs is greater than 0..Otherwise, returns undefined.\n */\n static create(\n context: Pick<ConnectionContext, \"getManagementClient\">,\n maxAutoRenewLockDurationInMs: number,\n receiveMode: \"peekLock\" | \"receiveAndDelete\",\n ): LockRenewer | undefined {\n if (receiveMode !== \"peekLock\") {\n return undefined;\n }\n\n if (maxAutoRenewLockDurationInMs <= 0) {\n return undefined;\n }\n\n return new LockRenewer(context, maxAutoRenewLockDurationInMs);\n }\n\n /**\n * Cancels all pending lock renewals for messages on given link and removes all entries from our internal cache.\n */\n stopAll(linkEntity: MinimalLink): void {\n logger.verbose(\n `${linkEntity.logPrefix} Clearing message renew lock timers for all the active messages.`,\n );\n\n const messagesForLink = this._messageRenewLockTimers.get(linkEntity.name);\n\n if (messagesForLink == null) {\n return;\n }\n\n for (const messageId of messagesForLink.keys()) {\n this._stopAndRemoveById(linkEntity, messagesForLink, messageId);\n }\n\n this._messageRenewLockTimers.delete(linkEntity.name);\n }\n\n /**\n * Stops lock renewal for a single message.\n *\n * @param bMessage - The message whose lock renewal we will stop.\n */\n stop(linkEntity: MinimalLink, bMessage: RenewableMessageProperties): void {\n const messageId = bMessage.messageId as string;\n\n const messagesForLink = this._messageRenewLockTimers.get(linkEntity.name);\n\n if (messagesForLink == null) {\n return;\n }\n\n this._stopAndRemoveById(linkEntity, messagesForLink, messageId);\n }\n\n /**\n * Starts lock renewal for a single message.\n *\n * @param bMessage - The message whose lock renewal we will start.\n */\n start(\n linkEntity: MinimalLink,\n bMessage: RenewableMessageProperties,\n onError: OnErrorNoContext,\n ): void {\n try {\n const logPrefix = linkEntity.logPrefix;\n\n if (bMessage.lockToken == null) {\n throw new Error(\n `Can't start auto lock renewal for message with message id '${bMessage.messageId}' since it does not have a lock token.`,\n );\n }\n\n const lockToken = bMessage.lockToken;\n const linkMessageMap = this._getOrCreateMapForLink(linkEntity);\n // - We need to renew locks before they expire by looking at bMessage.lockedUntilUtc.\n // - This autorenewal needs to happen **NO MORE** than maxAutoRenewDurationInMs\n // - We should be able to clear the renewal timer when the user's message handler\n // is done (whether it succeeds or fails).\n // Setting the messageId with undefined value in the linkMessageMap because we\n // track state by checking the presence of messageId in the map. It is removed from the map\n // when an attempt is made to settle the message (either by the user or by the sdk) OR\n // when the execution of user's message handler completes.\n linkMessageMap.set(bMessage.messageId as string, undefined);\n\n logger.verbose(\n `${logPrefix} message with id '${\n bMessage.messageId\n }' is locked until ${bMessage.lockedUntilUtc!.toString()}.`,\n );\n const totalAutoLockRenewDuration = Date.now() + this._maxAutoRenewDurationInMs;\n const totalAutoLockRenewDurationDate = new Date(totalAutoLockRenewDuration);\n logger.verbose(\n `${logPrefix} Total autolockrenew duration for message with id '${\n bMessage.messageId\n }' is: ${totalAutoLockRenewDurationDate.toString()}`,\n );\n\n const autoRenewLockTask = (): void => {\n const renewalNeededToMaintainLock =\n // if the lock expires _after_ our max auto-renew duration there's no reason to\n // spin up an auto-renewer - it's already held for the duration.\n totalAutoLockRenewDurationDate > bMessage.lockedUntilUtc!;\n\n if (!renewalNeededToMaintainLock) {\n logger.verbose(\n `${logPrefix} Autolockrenew not needed as message's lockedUntilUtc ${bMessage.lockedUntilUtc} is after the total autolockrenew duration ${totalAutoLockRenewDurationDate} for message with messageId '${bMessage.messageId}'. Hence we will stop the autoLockRenewTask.`,\n );\n this.stop(linkEntity, bMessage);\n } else if (Date.now() >= totalAutoLockRenewDuration) {\n // once we've exceeded the max amount of time we'll renew we can stop.\n logger.verbose(\n `${logPrefix} Current time ${new Date()} exceeds the total autolockrenew duration ${totalAutoLockRenewDurationDate} for message with messageId '${\n bMessage.messageId\n }'. Hence we will stop the autoLockRenewTask.`,\n );\n this.stop(linkEntity, bMessage);\n } else {\n if (linkMessageMap.has(bMessage.messageId as string)) {\n // TODO: We can run into problems with clock skew between the client and the server.\n // It would be better to calculate the duration based on the \"lockDuration\" property\n // of the queue. However, we do not have the management plane of the client ready for\n // now. Hence we rely on the lockedUntilUtc property on the message set by ServiceBus.\n const amount = this._calculateRenewAfterDuration(bMessage.lockedUntilUtc!);\n\n logger.verbose(\n `${logPrefix} Sleeping for ${amount} milliseconds while renewing the lock for message with id '${bMessage.messageId}'`,\n );\n // Setting the value of the messageId to the actual timer. This will be cleared when\n // an attempt is made to settle the message (either by the user or by the sdk) OR\n // when the execution of user's message handler completes.\n const autoRenewTimer = setTimeout(async () => {\n try {\n logger.verbose(\n `${logPrefix} Attempting to renew the lock for message with id '${bMessage.messageId}'.`,\n );\n\n bMessage.lockedUntilUtc = await this._context\n .getManagementClient(linkEntity.entityPath)\n .renewLock(lockToken, {\n associatedLinkName: linkEntity.name,\n });\n logger.verbose(\n `${logPrefix} Successfully renewed the lock for message with id '${bMessage.messageId}'. Starting next auto-lock-renew cycle for message.`,\n );\n\n autoRenewLockTask();\n } catch (err: any) {\n logger.logError(\n err,\n `${logPrefix} An error occurred while auto renewing the message lock '${bMessage.lockToken}' for message with id '${bMessage.messageId}'`,\n );\n onError(err);\n }\n }, amount);\n\n // Prevent the active Timer from keeping the Node.js event loop active.\n if (typeof autoRenewTimer.unref === \"function\") {\n autoRenewTimer.unref();\n }\n\n linkMessageMap.set(bMessage.messageId as string, autoRenewTimer);\n } else {\n logger.verbose(\n `${logPrefix} Looks like the message lock renew timer has already been cleared for message with id '${bMessage.messageId}'.`,\n );\n }\n }\n };\n\n // start\n autoRenewLockTask();\n } catch (err: any) {\n onError(err);\n }\n }\n\n private _getOrCreateMapForLink(linkEntity: MinimalLink): Map<string, NodeJS.Timeout | undefined> {\n if (!this._messageRenewLockTimers.has(linkEntity.name)) {\n this._messageRenewLockTimers.set(\n linkEntity.name,\n new Map<string, NodeJS.Timeout | undefined>(),\n );\n }\n\n return this._messageRenewLockTimers.get(linkEntity.name)!;\n }\n\n private _stopAndRemoveById(\n linkEntity: MinimalLink,\n linkMessageMap: Map<string, NodeJS.Timeout | undefined>,\n messageId: string | undefined,\n ): void {\n if (messageId == null) {\n throw new Error(\"Failed to stop auto lock renewal - no message ID\");\n }\n\n // TODO: messageId doesn't actually need to be unique. Perhaps we should use lockToken\n // instead?\n if (linkMessageMap.has(messageId)) {\n clearTimeout(linkMessageMap.get(messageId) as NodeJS.Timeout);\n logger.verbose(\n `${linkEntity.logPrefix} Cleared the message renew lock timer for message with id '${messageId}'.`,\n );\n linkMessageMap.delete(messageId);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"autoLockRenewer.js","sourceRoot":"","sources":["../../../src/core/autoLockRenewer.ts"],"names":[],"mappings":"AAAA,u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sBAAsB,CAAC,UAAuB;QACpD,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACvD,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAC9B,UAAU,CAAC,IAAI,EACf,IAAI,GAAG,EAAsC,CAC9C,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAE,CAAC;IAC5D,CAAC;IAEO,kBAAkB,CACxB,UAAuB,EACvB,cAAuD,EACvD,SAA6B;QAE7B,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtE,CAAC;QAED,sFAAsF;QACtF,WAAW;QACX,IAAI,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAmB,CAAC,CAAC;YAC9D,MAAM,CAAC,OAAO,CACZ,GAAG,UAAU,CAAC,SAAS,8DAA8D,SAAS,IAAI,CACnG,CAAC;YACF,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectionContext } from \"../connectionContext.js\";\nimport { receiverLogger as logger } from \"../log.js\";\nimport type { ServiceBusMessageImpl } from \"../serviceBusMessage.js\";\nimport { calculateRenewAfterDuration } from \"../util/utils.js\";\nimport type { LinkEntity } from \"./linkEntity.js\";\nimport type { OnErrorNoContext } from \"./messageReceiver.js\";\n\n/**\n * @internal\n */\nexport type RenewableMessageProperties = Readonly<\n Pick<ServiceBusMessageImpl, \"lockToken\" | \"messageId\">\n> &\n // updated when we renew the lock\n Pick<ServiceBusMessageImpl, \"lockedUntilUtc\">;\n\n/**\n * @internal\n */\ntype MinimalLink = Pick<LinkEntity<any>, \"name\" | \"logPrefix\" | \"entityPath\">;\n\n/**\n * Tracks locks for messages, renewing until a configurable duration.\n *\n * @internal\n */\nexport class LockRenewer {\n /**\n * A map of link names to individual maps for each\n * link that map a message ID to its auto-renewal timer.\n */\n private _messageRenewLockTimers = new Map<string, Map<string, NodeJS.Timeout | undefined>>();\n\n // just here for make unit testing a bit easier.\n private _calculateRenewAfterDuration: typeof calculateRenewAfterDuration;\n\n constructor(\n private _context: Pick<ConnectionContext, \"getManagementClient\">,\n private _maxAutoRenewDurationInMs: number,\n ) {\n this._calculateRenewAfterDuration = calculateRenewAfterDuration;\n }\n\n /**\n * Creates an AutoLockRenewer.\n *\n * @param linkEntity - Your link entity instance (probably 'this')\n * @param context - The connection context for your link entity (probably 'this._context')\n * @param options - The ReceiveOptions passed through to your message receiver.\n * @returns if the lock mode is peek lock (or if is unspecified, thus defaulting to peekLock)\n * and the options.maxAutoLockRenewalDurationInMs is greater than 0..Otherwise, returns undefined.\n */\n static create(\n context: Pick<ConnectionContext, \"getManagementClient\">,\n maxAutoRenewLockDurationInMs: number,\n receiveMode: \"peekLock\" | \"receiveAndDelete\",\n ): LockRenewer | undefined {\n if (receiveMode !== \"peekLock\") {\n return undefined;\n }\n\n if (maxAutoRenewLockDurationInMs <= 0) {\n return undefined;\n }\n\n return new LockRenewer(context, maxAutoRenewLockDurationInMs);\n }\n\n /**\n * Cancels all pending lock renewals for messages on given link and removes all entries from our internal cache.\n */\n stopAll(linkEntity: MinimalLink): void {\n logger.verbose(\n `${linkEntity.logPrefix} Clearing message renew lock timers for all the active messages.`,\n );\n\n const messagesForLink = this._messageRenewLockTimers.get(linkEntity.name);\n\n if (messagesForLink == null) {\n return;\n }\n\n for (const messageId of messagesForLink.keys()) {\n this._stopAndRemoveById(linkEntity, messagesForLink, messageId);\n }\n\n this._messageRenewLockTimers.delete(linkEntity.name);\n }\n\n /**\n * Stops lock renewal for a single message.\n *\n * @param bMessage - The message whose lock renewal we will stop.\n */\n stop(linkEntity: MinimalLink, bMessage: RenewableMessageProperties): void {\n const messageId = bMessage.messageId as string;\n\n const messagesForLink = this._messageRenewLockTimers.get(linkEntity.name);\n\n if (messagesForLink == null) {\n return;\n }\n\n this._stopAndRemoveById(linkEntity, messagesForLink, messageId);\n }\n\n /**\n * Starts lock renewal for a single message.\n *\n * @param bMessage - The message whose lock renewal we will start.\n */\n start(\n linkEntity: MinimalLink,\n bMessage: RenewableMessageProperties,\n onError: OnErrorNoContext,\n ): void {\n try {\n const logPrefix = linkEntity.logPrefix;\n\n if (bMessage.lockToken == null) {\n throw new Error(\n `Can't start auto lock renewal for message with message id '${bMessage.messageId}' since it does not have a lock token.`,\n );\n }\n\n const lockToken = bMessage.lockToken;\n const linkMessageMap = this._getOrCreateMapForLink(linkEntity);\n // - We need to renew locks before they expire by looking at bMessage.lockedUntilUtc.\n // - This autorenewal needs to happen **NO MORE** than maxAutoRenewDurationInMs\n // - We should be able to clear the renewal timer when the user's message handler\n // is done (whether it succeeds or fails).\n // Setting the messageId with undefined value in the linkMessageMap because we\n // track state by checking the presence of messageId in the map. It is removed from the map\n // when an attempt is made to settle the message (either by the user or by the sdk) OR\n // when the execution of user's message handler completes.\n linkMessageMap.set(bMessage.messageId as string, undefined);\n\n logger.verbose(\n `${logPrefix} message with id '${\n bMessage.messageId\n }' is locked until ${bMessage.lockedUntilUtc!.toString()}.`,\n );\n const totalAutoLockRenewDuration = Date.now() + this._maxAutoRenewDurationInMs;\n const totalAutoLockRenewDurationDate = new Date(totalAutoLockRenewDuration);\n logger.verbose(\n `${logPrefix} Total autolockrenew duration for message with id '${\n bMessage.messageId\n }' is: ${totalAutoLockRenewDurationDate.toString()}`,\n );\n\n const autoRenewLockTask = (): void => {\n const renewalNeededToMaintainLock =\n // if the lock expires _after_ our max auto-renew duration there's no reason to\n // spin up an auto-renewer - it's already held for the duration.\n totalAutoLockRenewDurationDate > bMessage.lockedUntilUtc!;\n\n if (!renewalNeededToMaintainLock) {\n logger.verbose(\n `${logPrefix} Autolockrenew not needed as message's lockedUntilUtc ${bMessage.lockedUntilUtc} is after the total autolockrenew duration ${totalAutoLockRenewDurationDate} for message with messageId '${bMessage.messageId}'. Hence we will stop the autoLockRenewTask.`,\n );\n this.stop(linkEntity, bMessage);\n } else if (Date.now() >= totalAutoLockRenewDuration) {\n // once we've exceeded the max amount of time we'll renew we can stop.\n logger.verbose(\n `${logPrefix} Current time ${new Date()} exceeds the total autolockrenew duration ${totalAutoLockRenewDurationDate} for message with messageId '${\n bMessage.messageId\n }'. Hence we will stop the autoLockRenewTask.`,\n );\n this.stop(linkEntity, bMessage);\n } else {\n if (linkMessageMap.has(bMessage.messageId as string)) {\n // TODO: We can run into problems with clock skew between the client and the server.\n // It would be better to calculate the duration based on the \"lockDuration\" property\n // of the queue. However, we do not have the management plane of the client ready for\n // now. Hence we rely on the lockedUntilUtc property on the message set by ServiceBus.\n const amount = this._calculateRenewAfterDuration(bMessage.lockedUntilUtc!);\n\n logger.verbose(\n `${logPrefix} Sleeping for ${amount} milliseconds while renewing the lock for message with id '${bMessage.messageId}'`,\n );\n // Setting the value of the messageId to the actual timer. This will be cleared when\n // an attempt is made to settle the message (either by the user or by the sdk) OR\n // when the execution of user's message handler completes.\n const autoRenewTimer = setTimeout(async () => {\n try {\n logger.verbose(\n `${logPrefix} Attempting to renew the lock for message with id '${bMessage.messageId}'.`,\n );\n\n bMessage.lockedUntilUtc = await this._context\n .getManagementClient(linkEntity.entityPath)\n .renewLock(lockToken, {\n associatedLinkName: linkEntity.name,\n });\n logger.verbose(\n `${logPrefix} Successfully renewed the lock for message with id '${bMessage.messageId}'. Starting next auto-lock-renew cycle for message.`,\n );\n\n autoRenewLockTask();\n } catch (err: any) {\n logger.logError(\n err,\n `${logPrefix} An error occurred while auto renewing the message lock '${bMessage.lockToken}' for message with id '${bMessage.messageId}'`,\n );\n onError(err);\n }\n }, amount);\n\n // Prevent the active Timer from keeping the Node.js event loop active.\n if (typeof autoRenewTimer.unref === \"function\") {\n autoRenewTimer.unref();\n }\n\n linkMessageMap.set(bMessage.messageId as string, autoRenewTimer);\n } else {\n logger.verbose(\n `${logPrefix} Looks like the message lock renew timer has already been cleared for message with id '${bMessage.messageId}'.`,\n );\n }\n }\n };\n\n // start\n autoRenewLockTask();\n } catch (err: any) {\n onError(err);\n }\n }\n\n private _getOrCreateMapForLink(linkEntity: MinimalLink): Map<string, NodeJS.Timeout | undefined> {\n if (!this._messageRenewLockTimers.has(linkEntity.name)) {\n this._messageRenewLockTimers.set(\n linkEntity.name,\n new Map<string, NodeJS.Timeout | undefined>(),\n );\n }\n\n return this._messageRenewLockTimers.get(linkEntity.name)!;\n }\n\n private _stopAndRemoveById(\n linkEntity: MinimalLink,\n linkMessageMap: Map<string, NodeJS.Timeout | undefined>,\n messageId: string | undefined,\n ): void {\n if (messageId == null) {\n throw new Error(\"Failed to stop auto lock renewal - no message ID\");\n }\n\n // TODO: messageId doesn't actually need to be unique. Perhaps we should use lockToken\n // instead?\n if (linkMessageMap.has(messageId)) {\n clearTimeout(linkMessageMap.get(messageId) as NodeJS.Timeout);\n logger.verbose(\n `${linkEntity.logPrefix} Cleared the message renew lock timer for message with id '${messageId}'.`,\n );\n linkMessageMap.delete(messageId);\n }\n }\n}\n"]}
|
|
@@ -24,18 +24,15 @@ export class BatchingReceiver extends MessageReceiver {
|
|
|
24
24
|
* @param options - Options for how you'd like to connect.
|
|
25
25
|
*/
|
|
26
26
|
constructor(identifier, connectionContext, entityPath, options) {
|
|
27
|
-
var _a, _b;
|
|
28
27
|
super(identifier, connectionContext, entityPath, "batching", options);
|
|
29
28
|
this._batchingReceiverLite = new BatchingReceiverLite(connectionContext, entityPath, async (abortSignal) => {
|
|
30
29
|
let lastError;
|
|
31
30
|
const rcvrOptions = this._createReceiverOptions(false, {
|
|
32
31
|
onError: (context) => {
|
|
33
|
-
|
|
34
|
-
lastError = (_a = context === null || context === void 0 ? void 0 : context.receiver) === null || _a === void 0 ? void 0 : _a.error;
|
|
32
|
+
lastError = context?.receiver?.error;
|
|
35
33
|
},
|
|
36
34
|
onSessionError: (context) => {
|
|
37
|
-
|
|
38
|
-
lastError = (_a = context === null || context === void 0 ? void 0 : context.session) === null || _a === void 0 ? void 0 : _a.error;
|
|
35
|
+
lastError = context?.session?.error;
|
|
39
36
|
},
|
|
40
37
|
onClose: async () => {
|
|
41
38
|
/** Nothing to do here - the next call will just fail so they'll get an appropriate error from somewhere else. */
|
|
@@ -52,8 +49,9 @@ export class BatchingReceiver extends MessageReceiver {
|
|
|
52
49
|
throw lastError;
|
|
53
50
|
}
|
|
54
51
|
return this.link;
|
|
55
|
-
}, this.receiveMode,
|
|
52
|
+
}, this.receiveMode, options.skipParsingBodyAsJson ?? false, options.skipConvertingDate ?? false);
|
|
56
53
|
}
|
|
54
|
+
_batchingReceiverLite;
|
|
57
55
|
get isReceivingMessages() {
|
|
58
56
|
return this._batchingReceiverLite.isReceivingMessages;
|
|
59
57
|
}
|
|
@@ -81,9 +79,12 @@ export class BatchingReceiver extends MessageReceiver {
|
|
|
81
79
|
async receive(maxMessageCount, maxWaitTimeInMs, maxTimeAfterFirstMessageInMs, options) {
|
|
82
80
|
throwErrorIfConnectionClosed(this._context);
|
|
83
81
|
try {
|
|
84
|
-
const messages = await this._batchingReceiverLite.receiveMessages(
|
|
82
|
+
const messages = await this._batchingReceiverLite.receiveMessages({
|
|
83
|
+
maxMessageCount,
|
|
85
84
|
maxWaitTimeInMs,
|
|
86
|
-
maxTimeAfterFirstMessageInMs
|
|
85
|
+
maxTimeAfterFirstMessageInMs,
|
|
86
|
+
...options,
|
|
87
|
+
});
|
|
87
88
|
if (this._lockRenewer) {
|
|
88
89
|
for (const message of messages) {
|
|
89
90
|
this._lockRenewer.start(this, message, (_error) => {
|
|
@@ -138,19 +139,28 @@ export function getRemainingWaitTimeInMsFn(maxWaitTimeInMs, maxTimeAfterFirstMes
|
|
|
138
139
|
* @internal
|
|
139
140
|
*/
|
|
140
141
|
export class BatchingReceiverLite {
|
|
142
|
+
_connectionContext;
|
|
143
|
+
entityPath;
|
|
144
|
+
_getCurrentReceiver;
|
|
145
|
+
_receiveMode;
|
|
146
|
+
// testing hook
|
|
147
|
+
_drainTimeoutInMs = receiveDrainTimeoutInMs;
|
|
141
148
|
constructor(_connectionContext, entityPath, _getCurrentReceiver, _receiveMode, _skipParsingBodyAsJson, _skipConvertingDate) {
|
|
142
149
|
this._connectionContext = _connectionContext;
|
|
143
150
|
this.entityPath = entityPath;
|
|
144
151
|
this._getCurrentReceiver = _getCurrentReceiver;
|
|
145
152
|
this._receiveMode = _receiveMode;
|
|
146
|
-
// testing hook
|
|
147
|
-
this._drainTimeoutInMs = receiveDrainTimeoutInMs;
|
|
148
153
|
this._createServiceBusMessage = (context) => {
|
|
149
154
|
return new ServiceBusMessageImpl(context.message, context.delivery, true, this._receiveMode, _skipParsingBodyAsJson, _skipConvertingDate);
|
|
150
155
|
};
|
|
151
156
|
this._getRemainingWaitTimeInMsFn = (maxWaitTimeInMs, maxTimeAfterFirstMessageInMs) => getRemainingWaitTimeInMsFn(maxWaitTimeInMs, maxTimeAfterFirstMessageInMs);
|
|
152
157
|
this.isReceivingMessages = false;
|
|
153
158
|
}
|
|
159
|
+
_createServiceBusMessage;
|
|
160
|
+
_getRemainingWaitTimeInMsFn;
|
|
161
|
+
_closeHandler;
|
|
162
|
+
_finalAction;
|
|
163
|
+
isReceivingMessages;
|
|
154
164
|
/**
|
|
155
165
|
* Receives a set of messages,
|
|
156
166
|
*
|
|
@@ -198,7 +208,7 @@ export class BatchingReceiverLite {
|
|
|
198
208
|
resolve();
|
|
199
209
|
}
|
|
200
210
|
function removeListeners() {
|
|
201
|
-
abortSignal
|
|
211
|
+
abortSignal?.removeEventListener("abort", onAbort);
|
|
202
212
|
receiver.removeListener(ReceiverEvents.receiverDrained, drainListener);
|
|
203
213
|
}
|
|
204
214
|
function onAbort() {
|
|
@@ -212,7 +222,7 @@ export class BatchingReceiverLite {
|
|
|
212
222
|
resolve();
|
|
213
223
|
}, timeToWaitInMs);
|
|
214
224
|
receiver.once(ReceiverEvents.receiverDrained, drainListener);
|
|
215
|
-
abortSignal
|
|
225
|
+
abortSignal?.addEventListener("abort", onAbort);
|
|
216
226
|
});
|
|
217
227
|
receiver.drainCredit();
|
|
218
228
|
logger.verbose(`${loggingPrefix} Draining leftover credits(${receiver.credit}), waiting for event_drained event, or timing out after ${timeToWaitInMs} milliseconds...`);
|
|
@@ -254,9 +264,8 @@ export class BatchingReceiverLite {
|
|
|
254
264
|
});
|
|
255
265
|
};
|
|
256
266
|
const onError = (context) => {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
let error = ((_b = context.session) === null || _b === void 0 ? void 0 : _b.error) || ((_c = context.receiver) === null || _c === void 0 ? void 0 : _c.error);
|
|
267
|
+
const eventType = context.session?.error != null ? "session_error" : "receiver_error";
|
|
268
|
+
let error = context.session?.error || context.receiver?.error;
|
|
260
269
|
if (error) {
|
|
261
270
|
error = translateServiceBusError(error);
|
|
262
271
|
logger.logError(error, `${loggingPrefix} '${eventType}' event occurred. Received an error`);
|
|
@@ -336,9 +345,8 @@ export class BatchingReceiverLite {
|
|
|
336
345
|
}
|
|
337
346
|
};
|
|
338
347
|
const onClose = async (context) => {
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
const error = ((_b = context.session) === null || _b === void 0 ? void 0 : _b.error) || ((_c = context.receiver) === null || _c === void 0 ? void 0 : _c.error);
|
|
348
|
+
const type = context.session?.error != null ? "session_closed" : "receiver_closed";
|
|
349
|
+
const error = context.session?.error || context.receiver?.error;
|
|
342
350
|
if (error) {
|
|
343
351
|
logger.logError(error, `${loggingPrefix} '${type}' event occurred. The associated error`);
|
|
344
352
|
}
|