@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceBusMessageBatch.js","sourceRoot":"","sources":["../../src/serviceBusMessageBatch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC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vC,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ServiceBusMessage } from \"./serviceBusMessage.js\";\nimport { toRheaMessage } from \"./serviceBusMessage.js\";\nimport {\n errorInvalidMessageTypeSingle,\n throwIfNotValidServiceBusMessage,\n throwTypeErrorIfParameterMissing,\n} from \"./util/errors.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { MessageAnnotations, Message as RheaMessage } from \"rhea-promise\";\nimport {\n messageProperties as RheaMessagePropertiesList,\n message as RheaMessageUtil,\n} from \"rhea-promise\";\nimport type { TracingContext } from \"@azure/core-tracing\";\nimport type { TryAddOptions } from \"./modelsToBeSharedWithEventHubs.js\";\nimport type { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { defaultDataTransformer } from \"./dataTransformer.js\";\nimport { instrumentMessage } from \"./diagnostics/instrumentServiceBusMessage.js\";\n\n/**\n * @internal\n * The amount of bytes to reserve as overhead for a small message.\n */\nconst smallMessageOverhead = 5;\n/**\n * @internal\n * The amount of bytes to reserve as overhead for a large message.\n */\nconst largeMessageOverhead = 8;\n/**\n * @internal\n * The maximum number of bytes that a message may be to be considered small.\n */\nconst smallMessageMaxBytes = 255;\n\n/**\n * A batch of messages that you can create using the {@link createBatch} method.\n *\n */\nexport interface ServiceBusMessageBatch {\n /**\n * Size of the batch in bytes after the events added to it have been encoded into a single AMQP\n * message.\n * @readonly\n */\n readonly sizeInBytes: number;\n\n /**\n * Number of messages added to the batch.\n * @readonly\n */\n readonly count: number;\n\n /**\n * The maximum size of the batch, in bytes. The `tryAddMessage` function on the batch will return `false`\n * if the message being added causes the size of the batch to exceed this limit. Use the `createMessageBatch()` method on\n * the `Sender` to set the maxSizeInBytes.\n * @readonly\n */\n readonly maxSizeInBytes: number;\n\n /**\n * Adds a message to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next event.\n *\n * @param message - The message to add to the batch.\n * @returns A boolean value indicating if the message has been added to the batch or not.\n */\n tryAddMessage(\n message: ServiceBusMessage | AmqpAnnotatedMessage,\n options?: TryAddOptions,\n ): boolean;\n\n /**\n * The AMQP message containing encoded events that were added to the batch.\n * Used internally by the `sendBatch()` method on the `Sender`.\n * This is not meant for the user to use directly.\n *\n * @readonly\n * @internal\n * @hidden\n */\n _generateMessage(): Buffer;\n\n /**\n * Gets the \"message\" span contexts that were created when adding events to the batch.\n * Used internally by the `sendBatch()` method to set up the right spans in traces if tracing is enabled.\n * @internal\n * @hidden\n */\n readonly _messageSpanContexts: TracingContext[];\n}\n\n/**\n * An internal class representing a batch of messages which can be used to send messages to Service Bus.\n *\n * @internal\n */\nexport class ServiceBusMessageBatchImpl implements ServiceBusMessageBatch {\n /**\n * Current size of the batch in bytes.\n */\n private _sizeInBytes: number;\n /**\n * Encoded amqp messages.\n */\n private _encodedMessages: Buffer[] = [];\n /**\n * List of 'message' span contexts.\n */\n private _spanContexts: TracingContext[] = [];\n /**\n * ServiceBusMessageBatch should not be constructed using `new ServiceBusMessageBatch()`\n * Use the `createBatch()` method on your `Sender` instead.\n * @internal\n * @hidden\n */\n constructor(\n private _context: ConnectionContext,\n private _maxSizeInBytes: number,\n ) {\n this._sizeInBytes = 0;\n this._batchMessageProperties = {};\n }\n\n /**\n * The maximum size of the batch, in bytes.\n * @readonly\n */\n get maxSizeInBytes(): number {\n return this._maxSizeInBytes;\n }\n\n /**\n * Size of the `ServiceBusMessageBatch` instance after the messages added to it have been\n * encoded into a single AMQP message.\n * @readonly\n */\n get sizeInBytes(): number {\n return this._sizeInBytes;\n }\n\n /**\n * Number of messages in the `ServiceBusMessageBatch` instance.\n * @readonly\n */\n get count(): number {\n return this._encodedMessages.length;\n }\n\n /**\n * Gets the \"message\" span contexts that were created when adding messages to the batch.\n * @internal\n * @hidden\n */\n get _messageSpanContexts(): TracingContext[] {\n return this._spanContexts;\n }\n\n /**\n * Generates an AMQP message that contains the provided encoded messages and annotations.\n *\n * @param encodedMessages - The already encoded messages to include in the AMQP batch.\n * @param annotations - The message annotations to set on the batch.\n * @param applicationProperties - The application properties to set on the batch.\n * @param messageProperties - The message properties to set on the batch.\n */\n private _generateBatch(\n encodedMessages: Buffer[],\n annotations?: MessageAnnotations,\n applicationProperties?: { [key: string]: any },\n messageProperties?: { [key: string]: string },\n ): Buffer {\n const batchEnvelope: RheaMessage = {\n body: RheaMessageUtil.data_sections(encodedMessages),\n message_annotations: annotations,\n application_properties: applicationProperties,\n };\n if (messageProperties) {\n for (const prop of RheaMessagePropertiesList) {\n if ((messageProperties as any)[prop]) {\n (batchEnvelope as any)[prop] = (messageProperties as any)[prop];\n }\n }\n }\n return RheaMessageUtil.encode(batchEnvelope);\n }\n\n /**\n * Represents the single AMQP message which is the result of encoding all the events\n * added into the `ServiceBusMessageBatch` instance.\n *\n * This is not meant for the user to use directly.\n *\n * When the `ServiceBusMessageBatch` instance is passed to the `sendBatch()` method on the `Sender`,\n * this single batched AMQP message is what gets sent over the wire to the service.\n * @readonly\n */\n _generateMessage(): Buffer {\n return this._generateBatch(\n this._encodedMessages,\n this._batchAnnotations,\n this._batchApplicationProperties,\n this._batchMessageProperties,\n );\n }\n\n /**\n * The message annotations to apply on the batch envelope.\n * This will reflect the message annotations on the first message\n * that was added to the batch.\n */\n private _batchAnnotations?: MessageAnnotations;\n /**\n * The message properties to apply on the batch envelope.\n * This will reflect the message properties on the first message\n * that was added to the batch.\n */\n private _batchMessageProperties?: { [key: string]: string };\n /**\n * The application properties to apply on the batch envelope.\n * This will reflect the application properties on the first message\n * that was added to the batch.\n */\n private _batchApplicationProperties?: { [key: string]: any };\n\n /**\n * Tries to add a message to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next message.\n *\n * @param originalMessage - An individual service bus message.\n * @returns A boolean value indicating if the message has been added to the batch or not.\n */\n public tryAddMessage(\n originalMessage: ServiceBusMessage | AmqpAnnotatedMessage,\n options: TryAddOptions = {},\n ): boolean {\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"message\", originalMessage);\n throwIfNotValidServiceBusMessage(originalMessage, errorInvalidMessageTypeSingle);\n\n const { message, spanContext } = instrumentMessage(\n originalMessage,\n options,\n this._context.config.entityPath!,\n this._context.config.host,\n \"publish\",\n );\n\n // Convert ServiceBusMessage to AmqpMessage.\n const amqpMessage = toRheaMessage(message, defaultDataTransformer);\n\n const encodedMessage = RheaMessageUtil.encode(amqpMessage);\n let currentSize = this._sizeInBytes;\n\n // The first time an event is added, we need to calculate\n // the overhead of creating an AMQP batch, including the\n // message_annotations, application_properties and message_properties\n // that are taken from the 1st message.\n if (this.count === 0) {\n if (amqpMessage.message_annotations) {\n this._batchAnnotations = amqpMessage.message_annotations;\n }\n if (amqpMessage.application_properties) {\n this._batchApplicationProperties = amqpMessage.application_properties;\n }\n for (const prop of RheaMessagePropertiesList) {\n if ((amqpMessage as any)[prop]) {\n (this._batchMessageProperties as any)[prop] = (amqpMessage as any)[prop];\n }\n }\n // Figure out the overhead of creating a batch by generating an empty batch\n // with the expected batch annotations.\n currentSize += this._generateBatch(\n [],\n this._batchAnnotations,\n this._batchApplicationProperties,\n this._batchMessageProperties,\n ).length;\n }\n\n const messageSize = encodedMessage.length;\n const messageOverhead =\n messageSize <= smallMessageMaxBytes ? smallMessageOverhead : largeMessageOverhead;\n currentSize += messageSize + messageOverhead;\n // Check if the size of the batch exceeds the maximum allowed size\n // once we add the new event to it.\n if (currentSize > this._maxSizeInBytes) {\n return false;\n }\n\n // The message will fit in the batch, so it is now safe to store it.\n this._encodedMessages.push(encodedMessage);\n if (spanContext) {\n this._spanContexts.push(spanContext);\n }\n\n this._sizeInBytes = currentSize;\n return true;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serviceBusMessageBatch.js","sourceRoot":"","sources":["../../src/serviceBusMessageBatch.ts"],"names":[],"mappings":"AAAA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AC,eAAe,EAAE,CAAC;YACvC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,oEAAoE;QACpE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3C,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACvC,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ServiceBusMessage } from \"./serviceBusMessage.js\";\nimport { toRheaMessage } from \"./serviceBusMessage.js\";\nimport {\n errorInvalidMessageTypeSingle,\n throwIfNotValidServiceBusMessage,\n throwTypeErrorIfParameterMissing,\n} from \"./util/errors.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { MessageAnnotations, Message as RheaMessage } from \"rhea-promise\";\nimport {\n messageProperties as RheaMessagePropertiesList,\n message as RheaMessageUtil,\n} from \"rhea-promise\";\nimport type { TracingContext } from \"@azure/core-tracing\";\nimport type { TryAddOptions } from \"./modelsToBeSharedWithEventHubs.js\";\nimport type { AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { defaultDataTransformer } from \"./dataTransformer.js\";\nimport { instrumentMessage } from \"./diagnostics/instrumentServiceBusMessage.js\";\n\n/**\n * @internal\n * The amount of bytes to reserve as overhead for a small message.\n */\nconst smallMessageOverhead = 5;\n/**\n * @internal\n * The amount of bytes to reserve as overhead for a large message.\n */\nconst largeMessageOverhead = 8;\n/**\n * @internal\n * The maximum number of bytes that a message may be to be considered small.\n */\nconst smallMessageMaxBytes = 255;\n\n/**\n * A batch of messages that you can create using the {@link createBatch} method.\n *\n */\nexport interface ServiceBusMessageBatch {\n /**\n * Size of the batch in bytes after the events added to it have been encoded into a single AMQP\n * message.\n * @readonly\n */\n readonly sizeInBytes: number;\n\n /**\n * Number of messages added to the batch.\n * @readonly\n */\n readonly count: number;\n\n /**\n * The maximum size of the batch, in bytes. The `tryAddMessage` function on the batch will return `false`\n * if the message being added causes the size of the batch to exceed this limit. Use the `createMessageBatch()` method on\n * the `Sender` to set the maxSizeInBytes.\n * @readonly\n */\n readonly maxSizeInBytes: number;\n\n /**\n * Adds a message to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next event.\n *\n * @param message - The message to add to the batch.\n * @returns A boolean value indicating if the message has been added to the batch or not.\n */\n tryAddMessage(\n message: ServiceBusMessage | AmqpAnnotatedMessage,\n options?: TryAddOptions,\n ): boolean;\n\n /**\n * The AMQP message containing encoded events that were added to the batch.\n * Used internally by the `sendBatch()` method on the `Sender`.\n * This is not meant for the user to use directly.\n *\n * @readonly\n * @internal\n * @hidden\n */\n _generateMessage(): Buffer;\n\n /**\n * Gets the \"message\" span contexts that were created when adding events to the batch.\n * Used internally by the `sendBatch()` method to set up the right spans in traces if tracing is enabled.\n * @internal\n * @hidden\n */\n readonly _messageSpanContexts: TracingContext[];\n}\n\n/**\n * An internal class representing a batch of messages which can be used to send messages to Service Bus.\n *\n * @internal\n */\nexport class ServiceBusMessageBatchImpl implements ServiceBusMessageBatch {\n /**\n * Current size of the batch in bytes.\n */\n private _sizeInBytes: number;\n /**\n * Encoded amqp messages.\n */\n private _encodedMessages: Buffer[] = [];\n /**\n * List of 'message' span contexts.\n */\n private _spanContexts: TracingContext[] = [];\n /**\n * ServiceBusMessageBatch should not be constructed using `new ServiceBusMessageBatch()`\n * Use the `createBatch()` method on your `Sender` instead.\n * @internal\n * @hidden\n */\n constructor(\n private _context: ConnectionContext,\n private _maxSizeInBytes: number,\n ) {\n this._sizeInBytes = 0;\n this._batchMessageProperties = {};\n }\n\n /**\n * The maximum size of the batch, in bytes.\n * @readonly\n */\n get maxSizeInBytes(): number {\n return this._maxSizeInBytes;\n }\n\n /**\n * Size of the `ServiceBusMessageBatch` instance after the messages added to it have been\n * encoded into a single AMQP message.\n * @readonly\n */\n get sizeInBytes(): number {\n return this._sizeInBytes;\n }\n\n /**\n * Number of messages in the `ServiceBusMessageBatch` instance.\n * @readonly\n */\n get count(): number {\n return this._encodedMessages.length;\n }\n\n /**\n * Gets the \"message\" span contexts that were created when adding messages to the batch.\n * @internal\n * @hidden\n */\n get _messageSpanContexts(): TracingContext[] {\n return this._spanContexts;\n }\n\n /**\n * Generates an AMQP message that contains the provided encoded messages and annotations.\n *\n * @param encodedMessages - The already encoded messages to include in the AMQP batch.\n * @param annotations - The message annotations to set on the batch.\n * @param applicationProperties - The application properties to set on the batch.\n * @param messageProperties - The message properties to set on the batch.\n */\n private _generateBatch(\n encodedMessages: Buffer[],\n annotations?: MessageAnnotations,\n applicationProperties?: { [key: string]: any },\n messageProperties?: { [key: string]: string },\n ): Buffer {\n const batchEnvelope: RheaMessage = {\n body: RheaMessageUtil.data_sections(encodedMessages),\n message_annotations: annotations,\n application_properties: applicationProperties,\n };\n if (messageProperties) {\n for (const prop of RheaMessagePropertiesList) {\n if ((messageProperties as any)[prop]) {\n (batchEnvelope as any)[prop] = (messageProperties as any)[prop];\n }\n }\n }\n return RheaMessageUtil.encode(batchEnvelope);\n }\n\n /**\n * Represents the single AMQP message which is the result of encoding all the events\n * added into the `ServiceBusMessageBatch` instance.\n *\n * This is not meant for the user to use directly.\n *\n * When the `ServiceBusMessageBatch` instance is passed to the `sendBatch()` method on the `Sender`,\n * this single batched AMQP message is what gets sent over the wire to the service.\n * @readonly\n */\n _generateMessage(): Buffer {\n return this._generateBatch(\n this._encodedMessages,\n this._batchAnnotations,\n this._batchApplicationProperties,\n this._batchMessageProperties,\n );\n }\n\n /**\n * The message annotations to apply on the batch envelope.\n * This will reflect the message annotations on the first message\n * that was added to the batch.\n */\n private _batchAnnotations?: MessageAnnotations;\n /**\n * The message properties to apply on the batch envelope.\n * This will reflect the message properties on the first message\n * that was added to the batch.\n */\n private _batchMessageProperties?: { [key: string]: string };\n /**\n * The application properties to apply on the batch envelope.\n * This will reflect the application properties on the first message\n * that was added to the batch.\n */\n private _batchApplicationProperties?: { [key: string]: any };\n\n /**\n * Tries to add a message to the batch if permitted by the batch's size limit.\n * **NOTE**: Always remember to check the return value of this method, before calling it again\n * for the next message.\n *\n * @param originalMessage - An individual service bus message.\n * @returns A boolean value indicating if the message has been added to the batch or not.\n */\n public tryAddMessage(\n originalMessage: ServiceBusMessage | AmqpAnnotatedMessage,\n options: TryAddOptions = {},\n ): boolean {\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"message\", originalMessage);\n throwIfNotValidServiceBusMessage(originalMessage, errorInvalidMessageTypeSingle);\n\n const { message, spanContext } = instrumentMessage(\n originalMessage,\n options,\n this._context.config.entityPath!,\n this._context.config.host,\n \"publish\",\n );\n\n // Convert ServiceBusMessage to AmqpMessage.\n const amqpMessage = toRheaMessage(message, defaultDataTransformer);\n\n const encodedMessage = RheaMessageUtil.encode(amqpMessage);\n let currentSize = this._sizeInBytes;\n\n // The first time an event is added, we need to calculate\n // the overhead of creating an AMQP batch, including the\n // message_annotations, application_properties and message_properties\n // that are taken from the 1st message.\n if (this.count === 0) {\n if (amqpMessage.message_annotations) {\n this._batchAnnotations = amqpMessage.message_annotations;\n }\n if (amqpMessage.application_properties) {\n this._batchApplicationProperties = amqpMessage.application_properties;\n }\n for (const prop of RheaMessagePropertiesList) {\n if ((amqpMessage as any)[prop]) {\n (this._batchMessageProperties as any)[prop] = (amqpMessage as any)[prop];\n }\n }\n // Figure out the overhead of creating a batch by generating an empty batch\n // with the expected batch annotations.\n currentSize += this._generateBatch(\n [],\n this._batchAnnotations,\n this._batchApplicationProperties,\n this._batchMessageProperties,\n ).length;\n }\n\n const messageSize = encodedMessage.length;\n const messageOverhead =\n messageSize <= smallMessageMaxBytes ? smallMessageOverhead : largeMessageOverhead;\n currentSize += messageSize + messageOverhead;\n // Check if the size of the batch exceeds the maximum allowed size\n // once we add the new event to it.\n if (currentSize > this._maxSizeInBytes) {\n return false;\n }\n\n // The message will fit in the batch, so it is now safe to store it.\n this._encodedMessages.push(encodedMessage);\n if (spanContext) {\n this._spanContexts.push(spanContext);\n }\n\n this._sizeInBytes = currentSize;\n return true;\n }\n}\n"]}
|
|
@@ -11,6 +11,15 @@ import { getPagedAsyncIterator } from "@azure/core-paging";
|
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
13
|
export class ServiceBusRuleManagerImpl {
|
|
14
|
+
_context;
|
|
15
|
+
_entityPath;
|
|
16
|
+
_retryOptions;
|
|
17
|
+
/**
|
|
18
|
+
* Denotes if close() was called on this sender
|
|
19
|
+
*/
|
|
20
|
+
_isClosed = false;
|
|
21
|
+
name;
|
|
22
|
+
entityPath;
|
|
14
23
|
/**
|
|
15
24
|
* @internal
|
|
16
25
|
* @throws Error if the underlying connection is closed.
|
|
@@ -19,10 +28,6 @@ export class ServiceBusRuleManagerImpl {
|
|
|
19
28
|
this._context = _context;
|
|
20
29
|
this._entityPath = _entityPath;
|
|
21
30
|
this._retryOptions = _retryOptions;
|
|
22
|
-
/**
|
|
23
|
-
* Denotes if close() was called on this sender
|
|
24
|
-
*/
|
|
25
|
-
this._isClosed = false;
|
|
26
31
|
throwErrorIfConnectionClosed(_context);
|
|
27
32
|
this.entityPath = _entityPath;
|
|
28
33
|
this.name = getUniqueName("ruleManager");
|
|
@@ -41,21 +46,26 @@ export class ServiceBusRuleManagerImpl {
|
|
|
41
46
|
}
|
|
42
47
|
else {
|
|
43
48
|
// Overload#1 - where the sqlExpression in the ruleAction is undefined
|
|
44
|
-
operOptions =
|
|
49
|
+
operOptions = { ...ruleActionOrOperationOptions, ...options };
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
|
-
return tracingClient.withSpan("ServiceBusRuleManager.createRule", operOptions
|
|
52
|
+
return tracingClient.withSpan("ServiceBusRuleManager.createRule", operOptions ?? {}, async (updatedOptions) => {
|
|
48
53
|
const addRuleOperationPromise = async () => {
|
|
49
54
|
return this._context
|
|
50
55
|
.getManagementClient(this._entityPath)
|
|
51
|
-
.addRule(ruleName, filter, sqlRuleAction
|
|
56
|
+
.addRule(ruleName, filter, sqlRuleAction?.sqlExpression, {
|
|
57
|
+
...updatedOptions,
|
|
58
|
+
associatedLinkName: this.name,
|
|
59
|
+
requestName: "addRule",
|
|
60
|
+
timeoutInMs: this._retryOptions.timeoutInMs,
|
|
61
|
+
});
|
|
52
62
|
};
|
|
53
63
|
const config = {
|
|
54
64
|
operation: addRuleOperationPromise,
|
|
55
65
|
connectionId: this._context.connectionId,
|
|
56
66
|
operationType: RetryOperationType.management,
|
|
57
67
|
retryOptions: this._retryOptions,
|
|
58
|
-
abortSignal: updatedOptions
|
|
68
|
+
abortSignal: updatedOptions?.abortSignal,
|
|
59
69
|
};
|
|
60
70
|
return retry(config);
|
|
61
71
|
});
|
|
@@ -64,16 +74,21 @@ export class ServiceBusRuleManagerImpl {
|
|
|
64
74
|
* Get all rules associated with the subscription.
|
|
65
75
|
*/
|
|
66
76
|
async getRules(options) {
|
|
67
|
-
return tracingClient.withSpan("ServiceBusRuleManager.getRules", options
|
|
77
|
+
return tracingClient.withSpan("ServiceBusRuleManager.getRules", options ?? {}, async (updatedOptions) => {
|
|
68
78
|
const getRulesOperationPromise = async () => {
|
|
69
|
-
return this._context.getManagementClient(this._entityPath).getRules(
|
|
79
|
+
return this._context.getManagementClient(this._entityPath).getRules({
|
|
80
|
+
...updatedOptions,
|
|
81
|
+
associatedLinkName: this.name,
|
|
82
|
+
requestName: "getRules",
|
|
83
|
+
timeoutInMs: this._retryOptions.timeoutInMs,
|
|
84
|
+
});
|
|
70
85
|
};
|
|
71
86
|
const config = {
|
|
72
87
|
operation: getRulesOperationPromise,
|
|
73
88
|
connectionId: this._context.connectionId,
|
|
74
89
|
operationType: RetryOperationType.management,
|
|
75
90
|
retryOptions: this._retryOptions,
|
|
76
|
-
abortSignal: updatedOptions
|
|
91
|
+
abortSignal: updatedOptions?.abortSignal,
|
|
77
92
|
};
|
|
78
93
|
return retry(config);
|
|
79
94
|
});
|
|
@@ -91,8 +106,12 @@ export class ServiceBusRuleManagerImpl {
|
|
|
91
106
|
const pagedResult = {
|
|
92
107
|
firstPageLink: 0,
|
|
93
108
|
getPage: async (pageLink, maxPageSize) => {
|
|
94
|
-
const top = maxPageSize
|
|
95
|
-
const rules = await this.getRules(
|
|
109
|
+
const top = maxPageSize ?? 100;
|
|
110
|
+
const rules = await this.getRules({
|
|
111
|
+
skip: pageLink,
|
|
112
|
+
maxCount: top,
|
|
113
|
+
...options,
|
|
114
|
+
});
|
|
96
115
|
return rules.length
|
|
97
116
|
? {
|
|
98
117
|
page: rules,
|
|
@@ -109,14 +128,19 @@ export class ServiceBusRuleManagerImpl {
|
|
|
109
128
|
async deleteRule(ruleName, options = {}) {
|
|
110
129
|
return tracingClient.withSpan("ServiceBusRuleManager.deleteRule", options, async (updatedOptions) => {
|
|
111
130
|
const removeRuleOperationPromise = async () => {
|
|
112
|
-
return this._context.getManagementClient(this._entityPath).removeRule(ruleName,
|
|
131
|
+
return this._context.getManagementClient(this._entityPath).removeRule(ruleName, {
|
|
132
|
+
...updatedOptions,
|
|
133
|
+
associatedLinkName: this.name,
|
|
134
|
+
requestName: "removeRule",
|
|
135
|
+
timeoutInMs: this._retryOptions.timeoutInMs,
|
|
136
|
+
});
|
|
113
137
|
};
|
|
114
138
|
const config = {
|
|
115
139
|
operation: removeRuleOperationPromise,
|
|
116
140
|
connectionId: this._context.connectionId,
|
|
117
141
|
operationType: RetryOperationType.management,
|
|
118
142
|
retryOptions: this._retryOptions,
|
|
119
|
-
abortSignal: updatedOptions
|
|
143
|
+
abortSignal: updatedOptions?.abortSignal,
|
|
120
144
|
};
|
|
121
145
|
return retry(config);
|
|
122
146
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceBusRuleManager.js","sourceRoot":"","sources":["../../src/serviceBusRuleManager.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,kBAAkB,E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CAAC,UAAU,CAAC,QAAgB,EAAE,UAA4B,EAAE;QAC/D,OAAO,aAAa,CAAC,QAAQ,CAC3B,kCAAkC,EAClC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,0BAA0B,GAAG,KAAK,IAAmB,EAAE;gBAC3D,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,QAAQ,kCACzE,cAAc,KACjB,kBAAkB,EAAE,IAAI,CAAC,IAAI,EAC7B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,WAAW,IAC3C,CAAC;YACL,CAAC,CAAC;YACF,MAAM,MAAM,GAAsB;gBAChC,SAAS,EAAE,0BAA0B;gBACrC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY;gBACxC,aAAa,EAAE,kBAAkB,CAAC,UAAU;gBAC5C,YAAY,EAAE,IAAI,CAAC,aAAa;gBAChC,WAAW,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW;aACzC,CAAC;YACF,OAAO,KAAK,CAAO,MAAM,CAAC,CAAC;QAC7B,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptionsBase } from \"./modelsToBeSharedWithEventHubs.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { RetryConfig, RetryOptions } from \"@azure/core-amqp\";\nimport { RetryOperationType, retry } from \"@azure/core-amqp\";\nimport type { CorrelationRuleFilter } from \"./core/managementClient.js\";\nimport { ruleManagerLogger as logger } from \"./log.js\";\nimport type { RuleProperties, SqlRuleAction } from \"./serializers/ruleResourceSerializer.js\";\nimport { isSqlRuleAction } from \"./serializers/ruleResourceSerializer.js\";\nimport { getUniqueName } from \"./util/utils.js\";\nimport { throwErrorIfConnectionClosed } from \"./util/errors.js\";\nimport type { SqlRuleFilter } from \"./serializers/ruleResourceSerializer.js\";\nimport { tracingClient } from \"./diagnostics/tracing.js\";\nimport type { PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { getPagedAsyncIterator } from \"@azure/core-paging\";\nimport type { OperationOptions } from \"@azure/core-client\";\nimport type { ListRequestOptions } from \"./serviceBusAtomManagementClient.js\";\n\n/**\n * Allows rules for a subscription to be managed. This rule manager requires only Listen claims, whereas the\n * {@link ServiceBusAdministrationClient} requires Manage claims.\n */\nexport interface ServiceBusRuleManager {\n /**\n * Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.\n *\n * @param ruleName - the name of the rule\n * @param filter - the filter expression that the rule evaluates.\n * @param options - The options that can be used to abort, trace and control other configurations on the request.\n */\n createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n options?: OperationOptionsBase,\n ): Promise<void>;\n /**\n * Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.\n *\n * @param ruleName - the name of the rule\n * @param filter - the filter expression that the rule evaluates.\n * @param ruleAction - The SQL like expression that can be executed on the message should the associated filter apply.\n * @param options - The options that can be used to abort, trace and control other configurations on the request.\n */\n createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n ruleAction?: SqlRuleAction,\n options?: OperationOptionsBase,\n ): Promise<void>;\n /**\n * Deletes a rule.\n *\n * @param ruleName - the name of the rule\n */\n deleteRule(ruleName: string, options?: OperationOptionsBase): Promise<void>;\n /**\n * Returns an async iterable iterator to list all the rules\n * under the specified subscription.\n *\n * .byPage() returns an async iterable iterator to list the rules in pages.\n *\n * @returns An asyncIterableIterator that supports paging.\n */\n listRules(options?: OperationOptions): PagedAsyncIterableIterator<RuleProperties>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusRuleManagerImpl implements ServiceBusRuleManager {\n /**\n * Denotes if close() was called on this sender\n */\n private _isClosed: boolean = false;\n private name: string;\n public entityPath: string;\n\n /**\n * @internal\n * @throws Error if the underlying connection is closed.\n */\n constructor(\n private _context: ConnectionContext,\n private _entityPath: string,\n private _retryOptions: RetryOptions = {},\n ) {\n throwErrorIfConnectionClosed(_context);\n this.entityPath = _entityPath;\n this.name = getUniqueName(\"ruleManager\");\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n /**\n * Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.\n *\n * @param ruleName - the name of the rule\n * @param filter - the filter expression that the rule evaluates.\n * @param options - The options that can be used to abort, trace and control other configurations on the request.\n */\n createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n options?: OperationOptions,\n ): Promise<void>;\n /**\n * Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.\n *\n * @param ruleName - the name of the rule\n * @param filter - the filter expression that the rule evaluates.\n * @param ruleAction - The SQL like expression that can be executed on the message should the associated filter apply.\n * @param options - The options that can be used to abort, trace and control other configurations on the request.\n */\n createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n ruleAction?: SqlRuleAction,\n options?: OperationOptions,\n ): Promise<void>;\n async createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n ruleActionOrOperationOptions?: SqlRuleAction | OperationOptionsBase,\n options: OperationOptions = {},\n ): Promise<void> {\n let sqlRuleAction: SqlRuleAction | undefined = undefined;\n let operOptions: OperationOptions | undefined;\n if (ruleActionOrOperationOptions) {\n if (isSqlRuleAction(ruleActionOrOperationOptions)) {\n // Overload#2 - where the sqlExpression in the ruleAction is defined\n sqlRuleAction = ruleActionOrOperationOptions;\n operOptions = options;\n } else {\n // Overload#1 - where the sqlExpression in the ruleAction is undefined\n operOptions = { ...ruleActionOrOperationOptions, ...options };\n }\n }\n\n return tracingClient.withSpan(\n \"ServiceBusRuleManager.createRule\",\n operOptions ?? {},\n async (updatedOptions) => {\n const addRuleOperationPromise = async (): Promise<void> => {\n return this._context\n .getManagementClient(this._entityPath)\n .addRule(ruleName, filter, sqlRuleAction?.sqlExpression, {\n ...updatedOptions,\n associatedLinkName: this.name,\n requestName: \"addRule\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<void> = {\n operation: addRuleOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: updatedOptions?.abortSignal,\n };\n return retry<void>(config);\n },\n );\n }\n\n /**\n * Get all rules associated with the subscription.\n */\n private async getRules(\n options?: ListRequestOptions & OperationOptions,\n ): Promise<RuleProperties[]> {\n return tracingClient.withSpan(\n \"ServiceBusRuleManager.getRules\",\n options ?? {},\n async (updatedOptions) => {\n const getRulesOperationPromise = async (): Promise<RuleProperties[]> => {\n return this._context.getManagementClient(this._entityPath).getRules({\n ...updatedOptions,\n associatedLinkName: this.name,\n requestName: \"getRules\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<RuleProperties[]> = {\n operation: getRulesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: updatedOptions?.abortSignal,\n };\n return retry<RuleProperties[]>(config);\n },\n );\n }\n\n /**\n * Returns an async iterable iterator to list all the rules\n * under the specified subscription.\n *\n * .byPage() returns an async iterable iterator to list the rules in pages.\n *\n * @returns An asyncIterableIterator that supports paging.\n */\n public listRules(\n options?: OperationOptions,\n ): PagedAsyncIterableIterator<RuleProperties, RuleProperties[], { maxPageSize?: number }> {\n logger.verbose(`Performing operation - listRules() with options: %j`, options);\n const pagedResult: PagedResult<RuleProperties[], { maxPageSize?: number }, number> = {\n firstPageLink: 0,\n getPage: async (pageLink, maxPageSize) => {\n const top = maxPageSize ?? 100;\n const rules = await this.getRules({\n skip: pageLink,\n maxCount: top,\n ...options,\n });\n return rules.length\n ? {\n page: rules,\n nextPageLink: rules.length > 0 ? pageLink + rules.length : undefined,\n }\n : undefined;\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n }\n\n /**\n * Deletes a rule.\n */\n async deleteRule(ruleName: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ServiceBusRuleManager.deleteRule\",\n options,\n async (updatedOptions) => {\n const removeRuleOperationPromise = async (): Promise<void> => {\n return this._context.getManagementClient(this._entityPath).removeRule(ruleName, {\n ...updatedOptions,\n associatedLinkName: this.name,\n requestName: \"removeRule\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<void> = {\n operation: removeRuleOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: updatedOptions?.abortSignal,\n };\n return retry<void>(config);\n },\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serviceBusRuleManager.js","sourceRoot":"","sources":["../../src/serviceBusRuleManager.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAoD3D;;GAEG;AACH,MAAM,OAAO,yBAAyB;IAa1B;IACA;IACA;IAdV;;OAEG;IACK,SAAS,GAAY,KAAK,CAAC;IAC3B,IAAI,CAAS;IACd,UAAU,CAAS;IAE1B;;;OAGG;IACH,YACU,QAA2B,EAC3B,WAAmB,EACnB,gBAA8B,EAAE;QAFhC,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,gBAAW,GAAX,WAAW,CA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a;gBAChC,WAAW,EAAE,cAAc,EAAE,WAAW;aACzC,CAAC;YACF,OAAO,KAAK,CAAO,MAAM,CAAC,CAAC;QAC7B,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptionsBase } from \"./modelsToBeSharedWithEventHubs.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport type { RetryConfig, RetryOptions } from \"@azure/core-amqp\";\nimport { RetryOperationType, retry } from \"@azure/core-amqp\";\nimport type { CorrelationRuleFilter } from \"./core/managementClient.js\";\nimport { ruleManagerLogger as logger } from \"./log.js\";\nimport type { RuleProperties, SqlRuleAction } from \"./serializers/ruleResourceSerializer.js\";\nimport { isSqlRuleAction } from \"./serializers/ruleResourceSerializer.js\";\nimport { getUniqueName } from \"./util/utils.js\";\nimport { throwErrorIfConnectionClosed } from \"./util/errors.js\";\nimport type { SqlRuleFilter } from \"./serializers/ruleResourceSerializer.js\";\nimport { tracingClient } from \"./diagnostics/tracing.js\";\nimport type { PagedAsyncIterableIterator, PagedResult } from \"@azure/core-paging\";\nimport { getPagedAsyncIterator } from \"@azure/core-paging\";\nimport type { OperationOptions } from \"@azure/core-client\";\nimport type { ListRequestOptions } from \"./serviceBusAtomManagementClient.js\";\n\n/**\n * Allows rules for a subscription to be managed. This rule manager requires only Listen claims, whereas the\n * {@link ServiceBusAdministrationClient} requires Manage claims.\n */\nexport interface ServiceBusRuleManager {\n /**\n * Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.\n *\n * @param ruleName - the name of the rule\n * @param filter - the filter expression that the rule evaluates.\n * @param options - The options that can be used to abort, trace and control other configurations on the request.\n */\n createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n options?: OperationOptionsBase,\n ): Promise<void>;\n /**\n * Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.\n *\n * @param ruleName - the name of the rule\n * @param filter - the filter expression that the rule evaluates.\n * @param ruleAction - The SQL like expression that can be executed on the message should the associated filter apply.\n * @param options - The options that can be used to abort, trace and control other configurations on the request.\n */\n createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n ruleAction?: SqlRuleAction,\n options?: OperationOptionsBase,\n ): Promise<void>;\n /**\n * Deletes a rule.\n *\n * @param ruleName - the name of the rule\n */\n deleteRule(ruleName: string, options?: OperationOptionsBase): Promise<void>;\n /**\n * Returns an async iterable iterator to list all the rules\n * under the specified subscription.\n *\n * .byPage() returns an async iterable iterator to list the rules in pages.\n *\n * @returns An asyncIterableIterator that supports paging.\n */\n listRules(options?: OperationOptions): PagedAsyncIterableIterator<RuleProperties>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusRuleManagerImpl implements ServiceBusRuleManager {\n /**\n * Denotes if close() was called on this sender\n */\n private _isClosed: boolean = false;\n private name: string;\n public entityPath: string;\n\n /**\n * @internal\n * @throws Error if the underlying connection is closed.\n */\n constructor(\n private _context: ConnectionContext,\n private _entityPath: string,\n private _retryOptions: RetryOptions = {},\n ) {\n throwErrorIfConnectionClosed(_context);\n this.entityPath = _entityPath;\n this.name = getUniqueName(\"ruleManager\");\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n /**\n * Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.\n *\n * @param ruleName - the name of the rule\n * @param filter - the filter expression that the rule evaluates.\n * @param options - The options that can be used to abort, trace and control other configurations on the request.\n */\n createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n options?: OperationOptions,\n ): Promise<void>;\n /**\n * Adds a rule to the current subscription to filter the messages reaching from topic to the subscription.\n *\n * @param ruleName - the name of the rule\n * @param filter - the filter expression that the rule evaluates.\n * @param ruleAction - The SQL like expression that can be executed on the message should the associated filter apply.\n * @param options - The options that can be used to abort, trace and control other configurations on the request.\n */\n createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n ruleAction?: SqlRuleAction,\n options?: OperationOptions,\n ): Promise<void>;\n async createRule(\n ruleName: string,\n filter: SqlRuleFilter | CorrelationRuleFilter,\n ruleActionOrOperationOptions?: SqlRuleAction | OperationOptionsBase,\n options: OperationOptions = {},\n ): Promise<void> {\n let sqlRuleAction: SqlRuleAction | undefined = undefined;\n let operOptions: OperationOptions | undefined;\n if (ruleActionOrOperationOptions) {\n if (isSqlRuleAction(ruleActionOrOperationOptions)) {\n // Overload#2 - where the sqlExpression in the ruleAction is defined\n sqlRuleAction = ruleActionOrOperationOptions;\n operOptions = options;\n } else {\n // Overload#1 - where the sqlExpression in the ruleAction is undefined\n operOptions = { ...ruleActionOrOperationOptions, ...options };\n }\n }\n\n return tracingClient.withSpan(\n \"ServiceBusRuleManager.createRule\",\n operOptions ?? {},\n async (updatedOptions) => {\n const addRuleOperationPromise = async (): Promise<void> => {\n return this._context\n .getManagementClient(this._entityPath)\n .addRule(ruleName, filter, sqlRuleAction?.sqlExpression, {\n ...updatedOptions,\n associatedLinkName: this.name,\n requestName: \"addRule\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<void> = {\n operation: addRuleOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: updatedOptions?.abortSignal,\n };\n return retry<void>(config);\n },\n );\n }\n\n /**\n * Get all rules associated with the subscription.\n */\n private async getRules(\n options?: ListRequestOptions & OperationOptions,\n ): Promise<RuleProperties[]> {\n return tracingClient.withSpan(\n \"ServiceBusRuleManager.getRules\",\n options ?? {},\n async (updatedOptions) => {\n const getRulesOperationPromise = async (): Promise<RuleProperties[]> => {\n return this._context.getManagementClient(this._entityPath).getRules({\n ...updatedOptions,\n associatedLinkName: this.name,\n requestName: \"getRules\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<RuleProperties[]> = {\n operation: getRulesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: updatedOptions?.abortSignal,\n };\n return retry<RuleProperties[]>(config);\n },\n );\n }\n\n /**\n * Returns an async iterable iterator to list all the rules\n * under the specified subscription.\n *\n * .byPage() returns an async iterable iterator to list the rules in pages.\n *\n * @returns An asyncIterableIterator that supports paging.\n */\n public listRules(\n options?: OperationOptions,\n ): PagedAsyncIterableIterator<RuleProperties, RuleProperties[], { maxPageSize?: number }> {\n logger.verbose(`Performing operation - listRules() with options: %j`, options);\n const pagedResult: PagedResult<RuleProperties[], { maxPageSize?: number }, number> = {\n firstPageLink: 0,\n getPage: async (pageLink, maxPageSize) => {\n const top = maxPageSize ?? 100;\n const rules = await this.getRules({\n skip: pageLink,\n maxCount: top,\n ...options,\n });\n return rules.length\n ? {\n page: rules,\n nextPageLink: rules.length > 0 ? pageLink + rules.length : undefined,\n }\n : undefined;\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n }\n\n /**\n * Deletes a rule.\n */\n async deleteRule(ruleName: string, options: OperationOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"ServiceBusRuleManager.deleteRule\",\n options,\n async (updatedOptions) => {\n const removeRuleOperationPromise = async (): Promise<void> => {\n return this._context.getManagementClient(this._entityPath).removeRule(ruleName, {\n ...updatedOptions,\n associatedLinkName: this.name,\n requestName: \"removeRule\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<void> = {\n operation: removeRuleOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: updatedOptions?.abortSignal,\n };\n return retry<void>(config);\n },\n );\n }\n}\n"]}
|
|
@@ -19,15 +19,127 @@ import { delay, isDefined } from "@azure/core-util";
|
|
|
19
19
|
* Describes the receiver for a Message Session.
|
|
20
20
|
*/
|
|
21
21
|
export class MessageSession extends LinkEntity {
|
|
22
|
+
identifier;
|
|
23
|
+
_providedSessionId;
|
|
24
|
+
/**
|
|
25
|
+
* Provides the duration until which the session is locked.
|
|
26
|
+
*/
|
|
27
|
+
sessionLockedUntilUtc;
|
|
28
|
+
/**
|
|
29
|
+
* The sessionId for the message session. Empty string is valid sessionId.
|
|
30
|
+
*/
|
|
31
|
+
sessionId;
|
|
32
|
+
/**
|
|
33
|
+
* The maximum number of concurrent sessions that the
|
|
34
|
+
* client should initiate.
|
|
35
|
+
* - **Default**: `1`.
|
|
36
|
+
*/
|
|
37
|
+
maxConcurrentSessions;
|
|
38
|
+
/**
|
|
39
|
+
* The maximum number of messages that should be
|
|
40
|
+
* processed concurrently in a session while in streaming mode. Once this limit has been reached,
|
|
41
|
+
* more messages will not be received until the user's message handler has completed processing current message.
|
|
42
|
+
* - **Default**: `1` (message in a session at a time).
|
|
43
|
+
*/
|
|
44
|
+
maxConcurrentCalls = 1;
|
|
45
|
+
/**
|
|
46
|
+
* The mode in which messages should be received.
|
|
47
|
+
* Default: ReceiveMode.peekLock
|
|
48
|
+
*/
|
|
49
|
+
receiveMode;
|
|
50
|
+
/**
|
|
51
|
+
* Indicates whether `Message.complete()` should be called
|
|
52
|
+
* automatically after the message processing is complete while receiving messages with handlers.
|
|
53
|
+
* Default: false.
|
|
54
|
+
*/
|
|
55
|
+
autoComplete;
|
|
56
|
+
/**
|
|
57
|
+
* The maximum duration within which the
|
|
58
|
+
* lock will be renewed automatically. This value should be greater than the longest message
|
|
59
|
+
* lock duration; for example, the `lockDuration` property on the received message.
|
|
60
|
+
*
|
|
61
|
+
* Default: `300 * 1000` (5 minutes);
|
|
62
|
+
*/
|
|
63
|
+
maxAutoRenewDurationInMs;
|
|
64
|
+
/**
|
|
65
|
+
* Should lock renewal happen automatically.
|
|
66
|
+
*/
|
|
67
|
+
autoRenewLock;
|
|
22
68
|
/**
|
|
23
69
|
* Denotes if we are currently receiving messages
|
|
24
70
|
*/
|
|
25
71
|
get isReceivingMessages() {
|
|
26
72
|
return this._batchingReceiverLite.isReceivingMessages || this._isReceivingMessagesForSubscriber;
|
|
27
73
|
}
|
|
74
|
+
_batchingReceiverLite;
|
|
75
|
+
_isReceivingMessagesForSubscriber;
|
|
76
|
+
/**
|
|
77
|
+
* Maintains a map of deliveries that
|
|
78
|
+
* are being actively disposed. It acts as a store for correlating the responses received for
|
|
79
|
+
* active dispositions.
|
|
80
|
+
*/
|
|
81
|
+
_deliveryDispositionMap = new Map();
|
|
82
|
+
/**
|
|
83
|
+
* The message handler provided by the user that will
|
|
84
|
+
* be wrapped inside _onAmqpMessage.
|
|
85
|
+
*/
|
|
86
|
+
_onMessage;
|
|
87
|
+
/**
|
|
88
|
+
* The error handler provided by the user that will be wrapped
|
|
89
|
+
* inside _onAmqpError.
|
|
90
|
+
*/
|
|
91
|
+
_onError;
|
|
92
|
+
/**
|
|
93
|
+
* If the user provided error handler is present then it will
|
|
94
|
+
* notify the user's error handler about the error.
|
|
95
|
+
*/
|
|
96
|
+
_notifyError;
|
|
97
|
+
/**
|
|
98
|
+
* The message handler that will be set as the handler on the
|
|
99
|
+
* underlying rhea receiver for the "receiver_close" event.
|
|
100
|
+
*/
|
|
101
|
+
_onAmqpClose;
|
|
102
|
+
/**
|
|
103
|
+
* The message handler that will be set as the handler on
|
|
104
|
+
* the underlying rhea receiver's session for the "session_error" event.
|
|
105
|
+
*/
|
|
106
|
+
_onSessionError;
|
|
107
|
+
/**
|
|
108
|
+
* The message handler that will be set as the handler on
|
|
109
|
+
* the underlying rhea receiver's session for the "session_close" event.
|
|
110
|
+
*/
|
|
111
|
+
_onSessionClose;
|
|
112
|
+
/**
|
|
113
|
+
* The message handler that will be set as the handler on the
|
|
114
|
+
* underlying rhea receiver for the "receiver_error" event.
|
|
115
|
+
*/
|
|
116
|
+
_onAmqpError;
|
|
117
|
+
/**
|
|
118
|
+
* The message handler that will be set as the handler on the
|
|
119
|
+
* underlying rhea receiver for the "settled" event.
|
|
120
|
+
*/
|
|
121
|
+
_onSettled;
|
|
122
|
+
/**
|
|
123
|
+
* The session lock renewal timer that keeps
|
|
124
|
+
* track of when the MessageSession is due for session lock renewal.
|
|
125
|
+
*/
|
|
126
|
+
_sessionLockRenewalTimer;
|
|
127
|
+
_totalAutoLockRenewDuration;
|
|
128
|
+
/**
|
|
129
|
+
* Whether to prevent the client from running JSON.parse() on the message body when receiving the message.
|
|
130
|
+
*/
|
|
131
|
+
skipParsingBodyAsJson;
|
|
132
|
+
/**
|
|
133
|
+
* Whether to skip converting Date type on properties of message annotations
|
|
134
|
+
* or application properties into numbers when receiving the message. By
|
|
135
|
+
* default, properties of Date type is converted into UNIX epoch number for
|
|
136
|
+
* compatibility.
|
|
137
|
+
*/
|
|
138
|
+
skipConvertingDate;
|
|
28
139
|
get receiverHelper() {
|
|
29
140
|
return this._receiverHelper;
|
|
30
141
|
}
|
|
142
|
+
_receiverHelper;
|
|
31
143
|
/**
|
|
32
144
|
* Ensures that the session lock is renewed before it expires. The lock will not be renewed for
|
|
33
145
|
* more than the configured totalAutoLockRenewDuration.
|
|
@@ -59,12 +171,11 @@ export class MessageSession extends LinkEntity {
|
|
|
59
171
|
}
|
|
60
172
|
}
|
|
61
173
|
async createRheaLink(options, _abortSignal) {
|
|
62
|
-
var _a, _b;
|
|
63
174
|
this._lastSBError = undefined;
|
|
64
175
|
let errorMessage = "";
|
|
65
176
|
const link = await this._context.connection.createReceiver(options);
|
|
66
177
|
this._intermediateLink = link;
|
|
67
|
-
const receivedSessionId =
|
|
178
|
+
const receivedSessionId = link.source?.filter?.[Constants.sessionFilterName];
|
|
68
179
|
if (this._providedSessionId === undefined && receivedSessionId === undefined) {
|
|
69
180
|
// When we ask for any sessions (passing option of session-filter: undefined),
|
|
70
181
|
// but don't receive one back, check whether service has sent any error.
|
|
@@ -108,14 +219,13 @@ export class MessageSession extends LinkEntity {
|
|
|
108
219
|
* Creates a new AMQP receiver under a new AMQP session.
|
|
109
220
|
*/
|
|
110
221
|
async _init(opts = {}) {
|
|
111
|
-
var _a, _b;
|
|
112
222
|
try {
|
|
113
223
|
const sessionOptions = this._createMessageSessionOptions(this.identifier, opts.timeoutInMs);
|
|
114
224
|
await this.initLink(sessionOptions, opts.abortSignal);
|
|
115
225
|
if (!this.link) {
|
|
116
226
|
throw new Error("INTERNAL ERROR: failed to create receiver but without an error.");
|
|
117
227
|
}
|
|
118
|
-
const receivedSessionId =
|
|
228
|
+
const receivedSessionId = this.link.source?.filter?.[Constants.sessionFilterName];
|
|
119
229
|
if (this._providedSessionId === undefined)
|
|
120
230
|
this.sessionId = receivedSessionId;
|
|
121
231
|
this.sessionLockedUntilUtc = convertTicksToDate(this.link.properties["com.microsoft:locked-until-utc"]);
|
|
@@ -167,6 +277,9 @@ export class MessageSession extends LinkEntity {
|
|
|
167
277
|
}, timeoutInMs);
|
|
168
278
|
return rcvrOptions;
|
|
169
279
|
}
|
|
280
|
+
_retryOptions;
|
|
281
|
+
_lastSBError;
|
|
282
|
+
_intermediateLink;
|
|
170
283
|
/**
|
|
171
284
|
* Constructs a MessageSession instance which lets you receive messages as batches
|
|
172
285
|
* or via callbacks using subscribe.
|
|
@@ -182,19 +295,6 @@ export class MessageSession extends LinkEntity {
|
|
|
182
295
|
});
|
|
183
296
|
this.identifier = identifier;
|
|
184
297
|
this._providedSessionId = _providedSessionId;
|
|
185
|
-
/**
|
|
186
|
-
* The maximum number of messages that should be
|
|
187
|
-
* processed concurrently in a session while in streaming mode. Once this limit has been reached,
|
|
188
|
-
* more messages will not be received until the user's message handler has completed processing current message.
|
|
189
|
-
* - **Default**: `1` (message in a session at a time).
|
|
190
|
-
*/
|
|
191
|
-
this.maxConcurrentCalls = 1;
|
|
192
|
-
/**
|
|
193
|
-
* Maintains a map of deliveries that
|
|
194
|
-
* are being actively disposed. It acts as a store for correlating the responses received for
|
|
195
|
-
* active dispositions.
|
|
196
|
-
*/
|
|
197
|
-
this._deliveryDispositionMap = new Map();
|
|
198
298
|
this._receiverHelper = new ReceiverHelper(() => ({
|
|
199
299
|
receiver: this.link,
|
|
200
300
|
logPrefix: this.logPrefix,
|
|
@@ -354,10 +454,9 @@ export class MessageSession extends LinkEntity {
|
|
|
354
454
|
this._subscribeImpl(onMessage, onError, options);
|
|
355
455
|
}
|
|
356
456
|
_subscribeImpl(onMessage, onError, options) {
|
|
357
|
-
var _a;
|
|
358
457
|
if (!options)
|
|
359
458
|
options = {};
|
|
360
|
-
if (
|
|
459
|
+
if (options.abortSignal?.aborted) {
|
|
361
460
|
throw new AbortError(StandardAbortMessage);
|
|
362
461
|
}
|
|
363
462
|
this._isReceivingMessagesForSubscriber = true;
|
|
@@ -511,9 +610,12 @@ export class MessageSession extends LinkEntity {
|
|
|
511
610
|
*/
|
|
512
611
|
async receiveMessages(maxMessageCount, maxWaitTimeInMs, maxTimeAfterFirstMessageInMs, options) {
|
|
513
612
|
try {
|
|
514
|
-
return await this._batchingReceiverLite.receiveMessages(
|
|
613
|
+
return await this._batchingReceiverLite.receiveMessages({
|
|
614
|
+
maxMessageCount,
|
|
515
615
|
maxWaitTimeInMs,
|
|
516
|
-
maxTimeAfterFirstMessageInMs
|
|
616
|
+
maxTimeAfterFirstMessageInMs,
|
|
617
|
+
...options,
|
|
618
|
+
});
|
|
517
619
|
}
|
|
518
620
|
catch (error) {
|
|
519
621
|
logger.logError(error, `${this.logPrefix} Rejecting receiveMessages() with error`);
|
|
@@ -591,7 +693,11 @@ export class MessageSession extends LinkEntity {
|
|
|
591
693
|
else if (operation === DispositionType.deadletter) {
|
|
592
694
|
const error = {
|
|
593
695
|
condition: Constants.deadLetterName,
|
|
594
|
-
info:
|
|
696
|
+
info: {
|
|
697
|
+
...options.propertiesToModify,
|
|
698
|
+
DeadLetterReason: options.deadLetterReason,
|
|
699
|
+
DeadLetterErrorDescription: options.deadLetterDescription,
|
|
700
|
+
},
|
|
595
701
|
};
|
|
596
702
|
delivery.reject(error);
|
|
597
703
|
}
|
|
@@ -604,14 +710,13 @@ export class MessageSession extends LinkEntity {
|
|
|
604
710
|
* @param options - Options that can be provided while creating the MessageSession.
|
|
605
711
|
*/
|
|
606
712
|
static async create(identifier, context, entityPath, sessionId, options) {
|
|
607
|
-
var _a, _b;
|
|
608
713
|
throwErrorIfConnectionClosed(context);
|
|
609
714
|
const messageSession = new MessageSession(identifier, context, entityPath, sessionId, options);
|
|
610
715
|
let timeoutInMs;
|
|
611
716
|
// Only passing client timeout in link properties for accepting next available
|
|
612
717
|
// session as this is the only long-polling scenario.
|
|
613
718
|
if (sessionId === undefined) {
|
|
614
|
-
timeoutInMs =
|
|
719
|
+
timeoutInMs = options.retryOptions?.timeoutInMs ?? Constants.defaultOperationTimeoutInMs;
|
|
615
720
|
// The number of milliseconds to use as the basis for calculating a random jitter amount
|
|
616
721
|
// opening receiver links. This is intended to ensure that multiple
|
|
617
722
|
// session operations don't timeout at the same exact moment.
|
|
@@ -638,7 +743,7 @@ export class MessageSession extends LinkEntity {
|
|
|
638
743
|
}
|
|
639
744
|
}
|
|
640
745
|
await messageSession._init({
|
|
641
|
-
abortSignal: options
|
|
746
|
+
abortSignal: options?.abortSignal,
|
|
642
747
|
timeoutInMs,
|
|
643
748
|
});
|
|
644
749
|
return messageSession;
|