@azure/service-bus 7.10.0-alpha.20250606.1 → 7.10.0-alpha.20250613.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"receiver.js","sourceRoot":"","sources":["../../../src/receivers/receiver.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAclC,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,qCAAqC,GACtC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAC;AAGxG;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4CAA4C,GAAG,IAAI,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAgP1C;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAmBjC,IAAY,S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CAAC;IAED;;;OAGG;IACK,oBAAoB;QAC1B,IACE,IAAI,CAAC,kBAAkB;YACvB,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE;YAChC,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,EACzC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IACE,IAAI,CAAC,iBAAiB;YACtB,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;YAC/B,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAC1C,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,uBAAuB,CAC7B,OAA0B,EAC1B,UAAkB,EAClB,OAAuB;QAEvB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACxF,MAAM,CAAC,OAAO,CACZ,IAAI,IAAI,CAAC,SAAS,eAAe,QAAQ,CAAC,IAAI,6CAA6C,OAAO,CAAC,kBAAkB,GAAG,CACzH,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,0BAA0B;QAChC,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC;YAChE,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACtC,CAAC;QACD,IACE,IAAI,CAAC,iBAAiB;YACtB,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;YAC/B,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAC1C,CAAC;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;QACrC,CAAC;QACD,OAAO;IACT,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PeekMessagesOptions,\n GetMessageIteratorOptions,\n MessageHandlers,\n ReceiveMessagesOptions,\n SubscribeOptions,\n DeleteMessagesOptions,\n PurgeMessagesOptions,\n} from \"../models.js\";\nimport type { OperationOptionsBase } from \"../modelsToBeSharedWithEventHubs.js\";\nimport type { ServiceBusReceivedMessage } from \"../serviceBusMessage.js\";\nimport type { ConnectionContext } from \"../connectionContext.js\";\nimport {\n getAlreadyReceivingErrorMsg,\n getReceiverClosedErrorMsg,\n InvalidMaxMessageCountError,\n throwErrorIfConnectionClosed,\n throwTypeErrorIfParameterMissing,\n throwTypeErrorIfParameterNotLong,\n throwErrorIfInvalidOperationOnMessage,\n throwTypeErrorIfParameterTypeMismatch,\n} from \"../util/errors.js\";\nimport type { ReceiveOptions } from \"../core/messageReceiver.js\";\nimport { StreamingReceiver } from \"../core/streamingReceiver.js\";\nimport { BatchingReceiver } from \"../core/batchingReceiver.js\";\nimport {\n abandonMessage,\n assertValidMessageHandlers,\n completeMessage,\n deadLetterMessage,\n deferMessage,\n getMessageIterator,\n} from \"./receiverCommon.js\";\nimport type Long from \"long\";\nimport type { ServiceBusMessageImpl, DeadLetterOptions } from \"../serviceBusMessage.js\";\nimport type { RetryConfig, RetryOptions } from \"@azure/core-amqp\";\nimport { Constants, RetryOperationType, retry } from \"@azure/core-amqp\";\nimport { LockRenewer } from \"../core/autoLockRenewer.js\";\nimport { receiverLogger as logger } from \"../log.js\";\nimport { translateServiceBusError } from \"../serviceBusError.js\";\nimport { ensureValidIdentifier } from \"../util/utils.js\";\nimport { toSpanOptions, tracingClient } from \"../diagnostics/tracing.js\";\nimport { extractSpanContextFromServiceBusMessage } from \"../diagnostics/instrumentServiceBusMessage.js\";\nimport type { TracingSpanLink } from \"@azure/core-tracing\";\n\n/**\n * The default time to wait for messages _after_ the first message\n * has been received.\n *\n * This timeout only applies to receiveMessages()\n *\n * @internal\n */\nexport const defaultMaxTimeAfterFirstMessageForBatchingMs = 1000;\n\n/**\n * The maximum number of messages to delete in a single batch. This cap is established and enforced by the service.\n * @internal\n */\nexport const MaxDeleteMessageCount = 4000;\n\n/**\n * A receiver that does not handle sessions.\n */\nexport interface ServiceBusReceiver {\n /**\n * A name used to identify the receiver. This can be used to correlate logs and exceptions.\n * If not specified or empty, a random unique one will be generated.\n */\n identifier: string;\n\n /**\n * Streams messages to message handlers.\n * @param handlers - A handler that gets called for messages and errors.\n * @param options - Options for subscribe.\n * @returns An object that can be closed, sending any remaining messages to `handlers` and\n * stopping new messages from arriving.\n */\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n /**\n * Causes the subscriber to stop receiving new messages.\n */\n close(): Promise<void>;\n };\n\n /**\n * Returns an iterator that can be used to receive messages from Service Bus.\n *\n * @param options - A set of options to control the receive operation.\n * - `abortSignal`: The signal to use to abort the ongoing operation.\n *\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws Error if current receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages.\n */\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage>;\n\n /**\n * Returns a promise that resolves to an array of messages received from Service Bus.\n *\n * @param maxMessageCount - The maximum number of messages to receive.\n * @param options - A set of options to control the receive operation.\n * - `maxWaitTimeInMs`: The maximum time to wait for the first message before returning an empty array if no messages are available.\n * - `abortSignal`: The signal to use to abort the ongoing operation.\n * @returns A promise that resolves with an array of messages.\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws Error if current receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages.\n */\n receiveMessages(\n maxMessageCount: number,\n options?: ReceiveMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Returns a promise that resolves to an array of deferred messages identified by given `sequenceNumbers`.\n * @param sequenceNumbers - The sequence number or an array of sequence numbers for the messages that need to be received.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns A list of messages identified by the given sequenceNumbers or an empty list if no messages are found.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while receiving deferred messages.\n */\n receiveDeferredMessages(\n sequenceNumbers: Long | Long[],\n options?: OperationOptionsBase,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Peek the next batch of active messages (including deferred but not deadlettered messages) on the\n * queue or subscription without modifying them.\n * - The first call to `peekMessages()` fetches the first active message. Each subsequent call fetches the\n * subsequent message.\n * - Unlike a \"received\" message, \"peeked\" message is a read-only version of the message.\n * It cannot be `Completed/Abandoned/Deferred/Deadlettered`.\n * @param maxMessageCount - The maximum number of messages to peek.\n * @param options - Options that allow to specify the maximum number of messages to peek,\n * the sequenceNumber to start peeking from or an abortSignal to abort the operation.\n */\n peekMessages(\n maxMessageCount: number,\n options?: PeekMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Delete messages. If no option is specified, all messages will be deleted.\n *\n * @param options - Options to configure the operation.\n * @returns number of messages that have been deleted.\n */\n deleteMessages(options: DeleteMessagesOptions): Promise<number>;\n\n /**\n * Attempts to purge all messages from an entity. Locked messages are not eligible for removal and\n * will remain in the entity.\n *\n * @param options - Options that allow to specify the cutoff time for deletion. Only messages that were enqueued\n * before this time will be deleted. If not specified, current time will be used.\n * @returns number of messages deleted.\n */\n purgeMessages(options?: PurgeMessagesOptions): Promise<number>;\n\n /**\n * Path of the entity for which the receiver has been created.\n */\n entityPath: string;\n /**\n * The receive mode used to create the receiver.\n */\n receiveMode: \"peekLock\" | \"receiveAndDelete\";\n /**\n * Returns `true` if either the receiver or the client that created it has been closed.\n * @readonly\n */\n isClosed: boolean;\n /**\n * Closes the receiver.\n * Once closed, the receiver cannot be used for any further operations.\n * Use the `createReceiver()` method on the ServiceBusClient to create a new Receiver.\n */\n close(): Promise<void>;\n /**\n * Removes the message from Service Bus.\n *\n * @throws Error with name `SessionLockLostError` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws Error with name `MessageLockLostError` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws Error with name `ServiceUnavailableError` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n */\n completeMessage(message: ServiceBusReceivedMessage): Promise<void>;\n /**\n * The lock held on the message by the receiver is let go, making the message available again in\n * Service Bus for another receive operation.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param propertiesToModify - The properties of the message to modify while abandoning the message.\n */\n abandonMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Defers the processing of the message. Save the `sequenceNumber` of the message, in order to\n * receive it message again in the future using the `receiveDeferredMessage` method.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param propertiesToModify - The properties of the message to modify while deferring the message\n */\n deferMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Moves the message to the deadletter sub-queue. To receive a deadletted message, create a new\n * QueueClient/SubscriptionClient using the path for the deadletter sub-queue.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param options - The DeadLetter options that can be provided while\n * rejecting the message.\n */\n deadLetterMessage(\n message: ServiceBusReceivedMessage,\n options?: DeadLetterOptions & { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Renews the lock on the message for the duration as specified during the Queue/Subscription\n * creation.\n * - Check the `lockedUntilUtc` property on the message for the time when the lock expires.\n * - If a message is not settled (using either `complete()`, `defer()` or `deadletter()`,\n * before its lock expires, then the message lands back in the Queue/Subscription for the next\n * receive operation.\n *\n * @returns New lock token expiry date and time in UTC format.\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws ServiceBusError if the service returns an error while renewing message lock.\n */\n renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusReceiverImpl implements ServiceBusReceiver {\n public identifier: string;\n private _retryOptions: RetryOptions;\n /**\n * Denotes if close() was called on this receiver\n */\n private _isClosed: boolean = false;\n\n /**\n * Instance of the BatchingReceiver class to use to receive messages in pull mode.\n */\n private _batchingReceiver?: BatchingReceiver;\n\n /**\n * Instance of the StreamingReceiver class to use to receive messages in push mode.\n */\n private _streamingReceiver?: StreamingReceiver;\n private _lockRenewer: LockRenewer | undefined;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|receiver:${this.entityPath}]`;\n }\n\n /**\n * @throws Error if the underlying connection is closed.\n */\n constructor(\n private _context: ConnectionContext,\n public entityPath: string,\n public receiveMode: \"peekLock\" | \"receiveAndDelete\",\n maxAutoRenewLockDurationInMs: number,\n private skipParsingBodyAsJson: boolean,\n private skipConvertingDate: boolean = false,\n retryOptions: RetryOptions = {},\n identifier?: string,\n ) {\n throwErrorIfConnectionClosed(_context);\n this._retryOptions = retryOptions;\n this._lockRenewer = LockRenewer.create(\n this._context,\n maxAutoRenewLockDurationInMs,\n receiveMode,\n );\n this.identifier = ensureValidIdentifier(this.entityPath, identifier);\n }\n\n private _throwIfAlreadyReceiving(): void {\n if (this._isReceivingMessages()) {\n const errorMessage = getAlreadyReceivingErrorMsg(this.entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is already receiving`);\n throw error;\n }\n }\n\n private _throwIfReceiverOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n const errorMessage = getReceiverClosedErrorMsg(this.entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is closed`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n async receiveMessages(\n maxMessageCount: number,\n options?: ReceiveMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"maxMessageCount\",\n maxMessageCount,\n );\n throwTypeErrorIfParameterTypeMismatch(\n this._context.connectionId,\n \"maxMessageCount\",\n maxMessageCount,\n \"number\",\n );\n\n if (isNaN(maxMessageCount) || maxMessageCount < 1) {\n throw new TypeError(InvalidMaxMessageCountError);\n }\n\n const receiveMessages = async (): Promise<ServiceBusReceivedMessage[]> => {\n if (!this._batchingReceiver || !this._context.messageReceivers[this._batchingReceiver.name]) {\n const receiveOptions: ReceiveOptions = {\n maxConcurrentCalls: 0,\n receiveMode: this.receiveMode,\n lockRenewer: this._lockRenewer,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n };\n this._batchingReceiver = this._createBatchingReceiver(\n this._context,\n this.entityPath,\n receiveOptions,\n );\n }\n\n const receivedMessages = await this._batchingReceiver.receive(\n maxMessageCount,\n options?.maxWaitTimeInMs ?? Constants.defaultOperationTimeoutInMs,\n defaultMaxTimeAfterFirstMessageForBatchingMs,\n options ?? {},\n );\n\n return receivedMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n connectionHost: this._context.config.host,\n connectionId: this._context.connectionId,\n operation: receiveMessages,\n operationType: RetryOperationType.receiveMessage,\n abortSignal: options?.abortSignal,\n retryOptions: this._retryOptions,\n };\n return retry<ServiceBusReceivedMessage[]>(config).catch((err) => {\n throw translateServiceBusError(err);\n });\n }\n\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage> {\n return getMessageIterator(this, options);\n }\n\n async receiveDeferredMessages(\n sequenceNumbers: Long | Long[],\n options: OperationOptionsBase = {},\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n throwTypeErrorIfParameterNotLong(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n\n const deferredSequenceNumbers = Array.isArray(sequenceNumbers)\n ? sequenceNumbers\n : [sequenceNumbers];\n const receiveDeferredMessagesOperationPromise = async (): Promise<\n ServiceBusReceivedMessage[]\n > => {\n const deferredMessages = await this._context\n .getManagementClient(this.entityPath)\n .receiveDeferredMessages(deferredSequenceNumbers, this.receiveMode, undefined, {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"receiveDeferredMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n });\n return deferredMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: receiveDeferredMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config);\n }\n\n async deleteMessages(options: DeleteMessagesOptions): Promise<number> {\n this._throwIfReceiverOrConnectionClosed();\n\n const deleteMessagesOperationPromise = (): Promise<number> => {\n return this._context\n .getManagementClient(this.entityPath)\n .deleteMessages(options.maxMessageCount, options?.beforeEnqueueTime, undefined, {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"deleteMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<number> = {\n operation: deleteMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<number>(config);\n }\n\n async purgeMessages(options?: PurgeMessagesOptions): Promise<number> {\n let deletedCount = await this.deleteMessages({\n maxMessageCount: MaxDeleteMessageCount,\n beforeEnqueueTime: options?.beforeEnqueueTime,\n });\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' deleted ${deletedCount} messages.`,\n );\n if (deletedCount === MaxDeleteMessageCount) {\n let batchCount = MaxDeleteMessageCount;\n while (batchCount === MaxDeleteMessageCount) {\n batchCount = await this.deleteMessages({\n maxMessageCount: MaxDeleteMessageCount,\n beforeEnqueueTime: options?.beforeEnqueueTime,\n });\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' deleted ${batchCount} messages.`,\n );\n deletedCount += batchCount;\n }\n }\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' purged ${deletedCount} messages.`,\n );\n return deletedCount;\n }\n\n // ManagementClient methods # Begin\n\n async peekMessages(\n maxMessageCount: number,\n options: PeekMessagesOptions = {},\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n\n const managementRequestOptions = {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"peekMessages\",\n timeoutInMs: this._retryOptions?.timeoutInMs,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n };\n // omitMessageBody is available at runtime, but only exported in experimental subpath\n const { fromSequenceNumber, omitMessageBody } = options as PeekMessagesOptions & {\n omitMessageBody: boolean;\n };\n const peekOperationPromise = async (): Promise<ServiceBusReceivedMessage[]> => {\n if (fromSequenceNumber !== undefined) {\n return this._context\n .getManagementClient(this.entityPath)\n .peekBySequenceNumber(\n fromSequenceNumber,\n maxMessageCount,\n undefined,\n omitMessageBody,\n managementRequestOptions,\n );\n } else {\n return this._context\n .getManagementClient(this.entityPath)\n .peek(maxMessageCount, omitMessageBody, managementRequestOptions);\n }\n };\n\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: peekOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config);\n }\n\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n close(): Promise<void>;\n } {\n assertValidMessageHandlers(handlers);\n throwErrorIfConnectionClosed(this._context);\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n\n options = {\n ...(options ?? {}),\n autoCompleteMessages: options?.autoCompleteMessages ?? true,\n };\n\n // When the user \"stops\" a streaming receiver (via the returned instance from 'subscribe' we just suspend\n // it, leaving the link open). This allows users to stop the flow of messages but still be able to settle messages\n // since the link itself hasn't been shut down.\n //\n // Users can, if they want, restart their subscription (since we've got a link already established).\n // So you'll have an instance here if the user has done:\n // 1. const subscription = receiver.subscribe()\n // 2. subscription.stop()\n // 3. receiver.subscribe()\n\n this._streamingReceiver =\n this._streamingReceiver ??\n new StreamingReceiver(this.identifier, this._context, this.entityPath, {\n ...options,\n receiveMode: this.receiveMode,\n retryOptions: this._retryOptions,\n lockRenewer: this._lockRenewer,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n });\n\n // this ensures that if the outer service bus client is closed that this receiver is cleaned up.\n // this mostly affects us if we're in the middle of init() - the connection (and receiver) are not yet\n // open but we do need to close the receiver to exit the init() loop.\n this._context.messageReceivers[this._streamingReceiver.name] = this._streamingReceiver;\n\n this._streamingReceiver.subscribe(handlers, options).catch((_) => {\n // (the error will already have been reported to the user)\n if (this._streamingReceiver) {\n delete this._context.messageReceivers[this._streamingReceiver.name];\n }\n });\n\n return {\n close: async (): Promise<void> => {\n return this._streamingReceiver?.stopReceivingMessages();\n },\n };\n }\n\n async completeMessage(message: ServiceBusReceivedMessage): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return completeMessage(msgImpl, this._context, this.entityPath, this._retryOptions);\n }\n\n async abandonMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return abandonMessage(\n msgImpl,\n this._context,\n this.entityPath,\n propertiesToModify,\n this._retryOptions,\n );\n }\n\n async deferMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return deferMessage(\n msgImpl,\n this._context,\n this.entityPath,\n propertiesToModify,\n this._retryOptions,\n );\n }\n\n async deadLetterMessage(\n message: ServiceBusReceivedMessage,\n options?: DeadLetterOptions & { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return deadLetterMessage(msgImpl, this._context, this.entityPath, options, this._retryOptions);\n }\n\n async renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n\n const tracingContext = extractSpanContextFromServiceBusMessage(message);\n const spanLinks: TracingSpanLink[] = tracingContext ? [{ tracingContext }] : [];\n\n return tracingClient.withSpan(\n \"ServiceBusReceiver.renewMessageLock\",\n {},\n () => {\n const msgImpl = message as ServiceBusMessageImpl;\n\n let associatedLinkName: string | undefined;\n if (msgImpl.delivery.link) {\n const associatedReceiver = this._context.getReceiverFromCache(msgImpl.delivery.link.name);\n associatedLinkName = associatedReceiver?.name;\n }\n return this._context\n .getManagementClient(this.entityPath)\n .renewLock(message.lockToken!, { associatedLinkName })\n .then((lockedUntil) => {\n message.lockedUntilUtc = lockedUntil;\n return lockedUntil;\n });\n },\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"receive\",\n \"client\",\n ),\n },\n );\n }\n\n async close(): Promise<void> {\n try {\n this._isClosed = true;\n if (this._context.connection && this._context.connection.isOpen()) {\n // Close the streaming receiver.\n if (this._streamingReceiver) {\n await this._streamingReceiver.close();\n }\n\n // Close the batching receiver.\n if (this._batchingReceiver) {\n await this._batchingReceiver.close();\n }\n }\n } catch (err: any) {\n logger.logError(err, `${this.logPrefix} An error occurred while closing the Receiver`);\n throw err;\n }\n }\n\n /**\n * Indicates whether the receiver is currently receiving messages or not.\n * When this returns true, new `registerMessageHandler()` or `receiveMessages()` calls cannot be made.\n */\n private _isReceivingMessages(): boolean {\n if (\n this._streamingReceiver &&\n this._streamingReceiver.isOpen() &&\n this._streamingReceiver.isSubscribeActive\n ) {\n return true;\n }\n if (\n this._batchingReceiver &&\n this._batchingReceiver.isOpen() &&\n this._batchingReceiver.isReceivingMessages\n ) {\n return true;\n }\n return false;\n }\n\n private _createBatchingReceiver(\n context: ConnectionContext,\n entityPath: string,\n options: ReceiveOptions,\n ): BatchingReceiver {\n const receiver = BatchingReceiver.create(this.identifier, context, entityPath, options);\n logger.verbose(\n `[${this.logPrefix}] receiver '${receiver.name}' created, with maxConcurrentCalls set to ${options.maxConcurrentCalls}.`,\n );\n\n return receiver;\n }\n\n /**\n * Helper function to retrieve any active receiver name, regardless of streaming or\n * batching if it exists. This is used for optimization on the service side\n */\n private _getAssociatedReceiverName(): string | undefined {\n if (this._streamingReceiver && this._streamingReceiver.isOpen()) {\n return this._streamingReceiver.name;\n }\n if (\n this._batchingReceiver &&\n this._batchingReceiver.isOpen() &&\n this._batchingReceiver.isReceivingMessages\n ) {\n return this._batchingReceiver.name;\n }\n return;\n }\n}\n"]}
1
+ {"version":3,"file":"receiver.js","sourceRoot":"","sources":["../../../src/receivers/receiver.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAclC,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAC3B,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,qCAAqC,GACtC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,cAAc,EACd,0BAA0B,EAC1B,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,uCAAuC,EAAE,MAAM,+CAA+C,CAAC;AAGxG;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4CAA4C,GAAG,IAAI,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,C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MIT License.\n\nimport type {\n PeekMessagesOptions,\n GetMessageIteratorOptions,\n MessageHandlers,\n ReceiveMessagesOptions,\n SubscribeOptions,\n DeleteMessagesOptions,\n PurgeMessagesOptions,\n} from \"../models.js\";\nimport type { OperationOptionsBase } from \"../modelsToBeSharedWithEventHubs.js\";\nimport type { ServiceBusReceivedMessage } from \"../serviceBusMessage.js\";\nimport type { ConnectionContext } from \"../connectionContext.js\";\nimport {\n getAlreadyReceivingErrorMsg,\n getReceiverClosedErrorMsg,\n InvalidMaxMessageCountError,\n throwErrorIfConnectionClosed,\n throwTypeErrorIfParameterMissing,\n throwTypeErrorIfParameterNotLong,\n throwErrorIfInvalidOperationOnMessage,\n throwTypeErrorIfParameterTypeMismatch,\n} from \"../util/errors.js\";\nimport type { ReceiveOptions } from \"../core/messageReceiver.js\";\nimport { StreamingReceiver } from \"../core/streamingReceiver.js\";\nimport { BatchingReceiver } from \"../core/batchingReceiver.js\";\nimport {\n abandonMessage,\n assertValidMessageHandlers,\n completeMessage,\n deadLetterMessage,\n deferMessage,\n getMessageIterator,\n} from \"./receiverCommon.js\";\nimport type Long from \"long\";\nimport type { ServiceBusMessageImpl, DeadLetterOptions } from \"../serviceBusMessage.js\";\nimport type { RetryConfig, RetryOptions } from \"@azure/core-amqp\";\nimport { Constants, RetryOperationType, retry } from \"@azure/core-amqp\";\nimport { LockRenewer } from \"../core/autoLockRenewer.js\";\nimport { receiverLogger as logger } from \"../log.js\";\nimport { translateServiceBusError } from \"../serviceBusError.js\";\nimport { ensureValidIdentifier } from \"../util/utils.js\";\nimport { toSpanOptions, tracingClient } from \"../diagnostics/tracing.js\";\nimport { extractSpanContextFromServiceBusMessage } from \"../diagnostics/instrumentServiceBusMessage.js\";\nimport type { TracingSpanLink } from \"@azure/core-tracing\";\n\n/**\n * The default time to wait for messages _after_ the first message\n * has been received.\n *\n * This timeout only applies to receiveMessages()\n *\n * @internal\n */\nexport const defaultMaxTimeAfterFirstMessageForBatchingMs = 1000;\n\n/**\n * The maximum number of messages to delete in a single batch. This cap is established and enforced by the service.\n * @internal\n */\nexport const MaxDeleteMessageCount = 500;\n\n/**\n * A receiver that does not handle sessions.\n */\nexport interface ServiceBusReceiver {\n /**\n * A name used to identify the receiver. This can be used to correlate logs and exceptions.\n * If not specified or empty, a random unique one will be generated.\n */\n identifier: string;\n\n /**\n * Streams messages to message handlers.\n * @param handlers - A handler that gets called for messages and errors.\n * @param options - Options for subscribe.\n * @returns An object that can be closed, sending any remaining messages to `handlers` and\n * stopping new messages from arriving.\n */\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n /**\n * Causes the subscriber to stop receiving new messages.\n */\n close(): Promise<void>;\n };\n\n /**\n * Returns an iterator that can be used to receive messages from Service Bus.\n *\n * @param options - A set of options to control the receive operation.\n * - `abortSignal`: The signal to use to abort the ongoing operation.\n *\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws Error if current receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages.\n */\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage>;\n\n /**\n * Returns a promise that resolves to an array of messages received from Service Bus.\n *\n * @param maxMessageCount - The maximum number of messages to receive.\n * @param options - A set of options to control the receive operation.\n * - `maxWaitTimeInMs`: The maximum time to wait for the first message before returning an empty array if no messages are available.\n * - `abortSignal`: The signal to use to abort the ongoing operation.\n * @returns A promise that resolves with an array of messages.\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws Error if current receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages.\n */\n receiveMessages(\n maxMessageCount: number,\n options?: ReceiveMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Returns a promise that resolves to an array of deferred messages identified by given `sequenceNumbers`.\n * @param sequenceNumbers - The sequence number or an array of sequence numbers for the messages that need to be received.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns A list of messages identified by the given sequenceNumbers or an empty list if no messages are found.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while receiving deferred messages.\n */\n receiveDeferredMessages(\n sequenceNumbers: Long | Long[],\n options?: OperationOptionsBase,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Peek the next batch of active messages (including deferred but not deadlettered messages) on the\n * queue or subscription without modifying them.\n * - The first call to `peekMessages()` fetches the first active message. Each subsequent call fetches the\n * subsequent message.\n * - Unlike a \"received\" message, \"peeked\" message is a read-only version of the message.\n * It cannot be `Completed/Abandoned/Deferred/Deadlettered`.\n * @param maxMessageCount - The maximum number of messages to peek.\n * @param options - Options that allow to specify the maximum number of messages to peek,\n * the sequenceNumber to start peeking from or an abortSignal to abort the operation.\n */\n peekMessages(\n maxMessageCount: number,\n options?: PeekMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Delete messages. If no option is specified, all messages will be deleted.\n *\n * @param options - Options to configure the operation.\n * @returns number of messages that have been deleted.\n */\n deleteMessages(options: DeleteMessagesOptions): Promise<number>;\n\n /**\n * Attempts to purge all messages from an entity. Locked messages are not eligible for removal and\n * will remain in the entity.\n *\n * @param options - Options that allow to specify the cutoff time for deletion. Only messages that were enqueued\n * before this time will be deleted. If not specified, current time will be used.\n * @returns number of messages deleted.\n */\n purgeMessages(options?: PurgeMessagesOptions): Promise<number>;\n\n /**\n * Path of the entity for which the receiver has been created.\n */\n entityPath: string;\n /**\n * The receive mode used to create the receiver.\n */\n receiveMode: \"peekLock\" | \"receiveAndDelete\";\n /**\n * Returns `true` if either the receiver or the client that created it has been closed.\n * @readonly\n */\n isClosed: boolean;\n /**\n * Closes the receiver.\n * Once closed, the receiver cannot be used for any further operations.\n * Use the `createReceiver()` method on the ServiceBusClient to create a new Receiver.\n */\n close(): Promise<void>;\n /**\n * Removes the message from Service Bus.\n *\n * @throws Error with name `SessionLockLostError` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws Error with name `MessageLockLostError` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws Error with name `ServiceUnavailableError` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n */\n completeMessage(message: ServiceBusReceivedMessage): Promise<void>;\n /**\n * The lock held on the message by the receiver is let go, making the message available again in\n * Service Bus for another receive operation.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param propertiesToModify - The properties of the message to modify while abandoning the message.\n */\n abandonMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Defers the processing of the message. Save the `sequenceNumber` of the message, in order to\n * receive it message again in the future using the `receiveDeferredMessage` method.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param propertiesToModify - The properties of the message to modify while deferring the message\n */\n deferMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Moves the message to the deadletter sub-queue. To receive a deadletted message, create a new\n * QueueClient/SubscriptionClient using the path for the deadletter sub-queue.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param options - The DeadLetter options that can be provided while\n * rejecting the message.\n */\n deadLetterMessage(\n message: ServiceBusReceivedMessage,\n options?: DeadLetterOptions & { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Renews the lock on the message for the duration as specified during the Queue/Subscription\n * creation.\n * - Check the `lockedUntilUtc` property on the message for the time when the lock expires.\n * - If a message is not settled (using either `complete()`, `defer()` or `deadletter()`,\n * before its lock expires, then the message lands back in the Queue/Subscription for the next\n * receive operation.\n *\n * @returns New lock token expiry date and time in UTC format.\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws ServiceBusError if the service returns an error while renewing message lock.\n */\n renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusReceiverImpl implements ServiceBusReceiver {\n public identifier: string;\n private _retryOptions: RetryOptions;\n /**\n * Denotes if close() was called on this receiver\n */\n private _isClosed: boolean = false;\n\n /**\n * Instance of the BatchingReceiver class to use to receive messages in pull mode.\n */\n private _batchingReceiver?: BatchingReceiver;\n\n /**\n * Instance of the StreamingReceiver class to use to receive messages in push mode.\n */\n private _streamingReceiver?: StreamingReceiver;\n private _lockRenewer: LockRenewer | undefined;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|receiver:${this.entityPath}]`;\n }\n\n /**\n * @throws Error if the underlying connection is closed.\n */\n constructor(\n private _context: ConnectionContext,\n public entityPath: string,\n public receiveMode: \"peekLock\" | \"receiveAndDelete\",\n maxAutoRenewLockDurationInMs: number,\n private skipParsingBodyAsJson: boolean,\n private skipConvertingDate: boolean = false,\n retryOptions: RetryOptions = {},\n identifier?: string,\n ) {\n throwErrorIfConnectionClosed(_context);\n this._retryOptions = retryOptions;\n this._lockRenewer = LockRenewer.create(\n this._context,\n maxAutoRenewLockDurationInMs,\n receiveMode,\n );\n this.identifier = ensureValidIdentifier(this.entityPath, identifier);\n }\n\n private _throwIfAlreadyReceiving(): void {\n if (this._isReceivingMessages()) {\n const errorMessage = getAlreadyReceivingErrorMsg(this.entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is already receiving`);\n throw error;\n }\n }\n\n private _throwIfReceiverOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n const errorMessage = getReceiverClosedErrorMsg(this.entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is closed`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n async receiveMessages(\n maxMessageCount: number,\n options?: ReceiveMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"maxMessageCount\",\n maxMessageCount,\n );\n throwTypeErrorIfParameterTypeMismatch(\n this._context.connectionId,\n \"maxMessageCount\",\n maxMessageCount,\n \"number\",\n );\n\n if (isNaN(maxMessageCount) || maxMessageCount < 1) {\n throw new TypeError(InvalidMaxMessageCountError);\n }\n\n const receiveMessages = async (): Promise<ServiceBusReceivedMessage[]> => {\n if (!this._batchingReceiver || !this._context.messageReceivers[this._batchingReceiver.name]) {\n const receiveOptions: ReceiveOptions = {\n maxConcurrentCalls: 0,\n receiveMode: this.receiveMode,\n lockRenewer: this._lockRenewer,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n };\n this._batchingReceiver = this._createBatchingReceiver(\n this._context,\n this.entityPath,\n receiveOptions,\n );\n }\n\n const receivedMessages = await this._batchingReceiver.receive(\n maxMessageCount,\n options?.maxWaitTimeInMs ?? Constants.defaultOperationTimeoutInMs,\n defaultMaxTimeAfterFirstMessageForBatchingMs,\n options ?? {},\n );\n\n return receivedMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n connectionHost: this._context.config.host,\n connectionId: this._context.connectionId,\n operation: receiveMessages,\n operationType: RetryOperationType.receiveMessage,\n abortSignal: options?.abortSignal,\n retryOptions: this._retryOptions,\n };\n return retry<ServiceBusReceivedMessage[]>(config).catch((err) => {\n throw translateServiceBusError(err);\n });\n }\n\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage> {\n return getMessageIterator(this, options);\n }\n\n async receiveDeferredMessages(\n sequenceNumbers: Long | Long[],\n options: OperationOptionsBase = {},\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n throwTypeErrorIfParameterNotLong(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n\n const deferredSequenceNumbers = Array.isArray(sequenceNumbers)\n ? sequenceNumbers\n : [sequenceNumbers];\n const receiveDeferredMessagesOperationPromise = async (): Promise<\n ServiceBusReceivedMessage[]\n > => {\n const deferredMessages = await this._context\n .getManagementClient(this.entityPath)\n .receiveDeferredMessages(deferredSequenceNumbers, this.receiveMode, undefined, {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"receiveDeferredMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n });\n return deferredMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: receiveDeferredMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config);\n }\n\n async deleteMessages(options: DeleteMessagesOptions): Promise<number> {\n this._throwIfReceiverOrConnectionClosed();\n\n const deleteMessagesOperationPromise = (): Promise<number> => {\n return this._context\n .getManagementClient(this.entityPath)\n .deleteMessages(options.maxMessageCount, options?.beforeEnqueueTime, undefined, {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"deleteMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<number> = {\n operation: deleteMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<number>(config);\n }\n\n async purgeMessages(options?: PurgeMessagesOptions): Promise<number> {\n let deletedCount = await this.deleteMessages({\n maxMessageCount: MaxDeleteMessageCount,\n beforeEnqueueTime: options?.beforeEnqueueTime,\n });\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' deleted ${deletedCount} messages.`,\n );\n if (deletedCount === MaxDeleteMessageCount) {\n let batchCount = MaxDeleteMessageCount;\n while (batchCount === MaxDeleteMessageCount) {\n batchCount = await this.deleteMessages({\n maxMessageCount: MaxDeleteMessageCount,\n beforeEnqueueTime: options?.beforeEnqueueTime,\n });\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' deleted ${batchCount} messages.`,\n );\n deletedCount += batchCount;\n }\n }\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' purged ${deletedCount} messages.`,\n );\n return deletedCount;\n }\n\n // ManagementClient methods # Begin\n\n async peekMessages(\n maxMessageCount: number,\n options: PeekMessagesOptions = {},\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n\n const managementRequestOptions = {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"peekMessages\",\n timeoutInMs: this._retryOptions?.timeoutInMs,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n };\n // omitMessageBody is available at runtime, but only exported in experimental subpath\n const { fromSequenceNumber, omitMessageBody } = options as PeekMessagesOptions & {\n omitMessageBody: boolean;\n };\n const peekOperationPromise = async (): Promise<ServiceBusReceivedMessage[]> => {\n if (fromSequenceNumber !== undefined) {\n return this._context\n .getManagementClient(this.entityPath)\n .peekBySequenceNumber(\n fromSequenceNumber,\n maxMessageCount,\n undefined,\n omitMessageBody,\n managementRequestOptions,\n );\n } else {\n return this._context\n .getManagementClient(this.entityPath)\n .peek(maxMessageCount, omitMessageBody, managementRequestOptions);\n }\n };\n\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: peekOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config);\n }\n\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n close(): Promise<void>;\n } {\n assertValidMessageHandlers(handlers);\n throwErrorIfConnectionClosed(this._context);\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n\n options = {\n ...(options ?? {}),\n autoCompleteMessages: options?.autoCompleteMessages ?? true,\n };\n\n // When the user \"stops\" a streaming receiver (via the returned instance from 'subscribe' we just suspend\n // it, leaving the link open). This allows users to stop the flow of messages but still be able to settle messages\n // since the link itself hasn't been shut down.\n //\n // Users can, if they want, restart their subscription (since we've got a link already established).\n // So you'll have an instance here if the user has done:\n // 1. const subscription = receiver.subscribe()\n // 2. subscription.stop()\n // 3. receiver.subscribe()\n\n this._streamingReceiver =\n this._streamingReceiver ??\n new StreamingReceiver(this.identifier, this._context, this.entityPath, {\n ...options,\n receiveMode: this.receiveMode,\n retryOptions: this._retryOptions,\n lockRenewer: this._lockRenewer,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n });\n\n // this ensures that if the outer service bus client is closed that this receiver is cleaned up.\n // this mostly affects us if we're in the middle of init() - the connection (and receiver) are not yet\n // open but we do need to close the receiver to exit the init() loop.\n this._context.messageReceivers[this._streamingReceiver.name] = this._streamingReceiver;\n\n this._streamingReceiver.subscribe(handlers, options).catch((_) => {\n // (the error will already have been reported to the user)\n if (this._streamingReceiver) {\n delete this._context.messageReceivers[this._streamingReceiver.name];\n }\n });\n\n return {\n close: async (): Promise<void> => {\n return this._streamingReceiver?.stopReceivingMessages();\n },\n };\n }\n\n async completeMessage(message: ServiceBusReceivedMessage): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return completeMessage(msgImpl, this._context, this.entityPath, this._retryOptions);\n }\n\n async abandonMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return abandonMessage(\n msgImpl,\n this._context,\n this.entityPath,\n propertiesToModify,\n this._retryOptions,\n );\n }\n\n async deferMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return deferMessage(\n msgImpl,\n this._context,\n this.entityPath,\n propertiesToModify,\n this._retryOptions,\n );\n }\n\n async deadLetterMessage(\n message: ServiceBusReceivedMessage,\n options?: DeadLetterOptions & { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return deadLetterMessage(msgImpl, this._context, this.entityPath, options, this._retryOptions);\n }\n\n async renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n\n const tracingContext = extractSpanContextFromServiceBusMessage(message);\n const spanLinks: TracingSpanLink[] = tracingContext ? [{ tracingContext }] : [];\n\n return tracingClient.withSpan(\n \"ServiceBusReceiver.renewMessageLock\",\n {},\n () => {\n const msgImpl = message as ServiceBusMessageImpl;\n\n let associatedLinkName: string | undefined;\n if (msgImpl.delivery.link) {\n const associatedReceiver = this._context.getReceiverFromCache(msgImpl.delivery.link.name);\n associatedLinkName = associatedReceiver?.name;\n }\n return this._context\n .getManagementClient(this.entityPath)\n .renewLock(message.lockToken!, { associatedLinkName })\n .then((lockedUntil) => {\n message.lockedUntilUtc = lockedUntil;\n return lockedUntil;\n });\n },\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"receive\",\n \"client\",\n ),\n },\n );\n }\n\n async close(): Promise<void> {\n try {\n this._isClosed = true;\n if (this._context.connection && this._context.connection.isOpen()) {\n // Close the streaming receiver.\n if (this._streamingReceiver) {\n await this._streamingReceiver.close();\n }\n\n // Close the batching receiver.\n if (this._batchingReceiver) {\n await this._batchingReceiver.close();\n }\n }\n } catch (err: any) {\n logger.logError(err, `${this.logPrefix} An error occurred while closing the Receiver`);\n throw err;\n }\n }\n\n /**\n * Indicates whether the receiver is currently receiving messages or not.\n * When this returns true, new `registerMessageHandler()` or `receiveMessages()` calls cannot be made.\n */\n private _isReceivingMessages(): boolean {\n if (\n this._streamingReceiver &&\n this._streamingReceiver.isOpen() &&\n this._streamingReceiver.isSubscribeActive\n ) {\n return true;\n }\n if (\n this._batchingReceiver &&\n this._batchingReceiver.isOpen() &&\n this._batchingReceiver.isReceivingMessages\n ) {\n return true;\n }\n return false;\n }\n\n private _createBatchingReceiver(\n context: ConnectionContext,\n entityPath: string,\n options: ReceiveOptions,\n ): BatchingReceiver {\n const receiver = BatchingReceiver.create(this.identifier, context, entityPath, options);\n logger.verbose(\n `[${this.logPrefix}] receiver '${receiver.name}' created, with maxConcurrentCalls set to ${options.maxConcurrentCalls}.`,\n );\n\n return receiver;\n }\n\n /**\n * Helper function to retrieve any active receiver name, regardless of streaming or\n * batching if it exists. This is used for optimization on the service side\n */\n private _getAssociatedReceiverName(): string | undefined {\n if (this._streamingReceiver && this._streamingReceiver.isOpen()) {\n return this._streamingReceiver.name;\n }\n if (\n this._batchingReceiver &&\n this._batchingReceiver.isOpen() &&\n this._batchingReceiver.isReceivingMessages\n ) {\n return this._batchingReceiver.name;\n }\n return;\n }\n}\n"]}
@@ -31,7 +31,7 @@ export interface ServiceBusSender {
31
31
  *
32
32
  * `await sender.sendMessages(message);`
33
33
  *
34
- * __This is because the batched messages are not capable of sending the larger messages yet. You'll hit the `force detached` error in this case otherwise. Read [service-bus-premium-messaging#large-messages-support](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support). More info at [#23014](https://github.com/Azure/azure-sdk-for-js/pull/23014).__
34
+ * __This is because the batched messages are not capable of sending the larger messages yet. You'll hit the `force detached` error in this case otherwise. Read [service-bus-premium-messaging#large-messages-support](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support). More info at [#23014](https://github.com/Azure/azure-sdk-for-js/pull/23014).__
35
35
  *
36
36
  * @param messages - A single message or an array of messages or a batch of messages created via the createBatch()
37
37
  * method to send.
@@ -1 +1 @@
1
- {"version":3,"file":"sender.js","sourceRoot":"","sources":["../../src/sender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,0CAA0C,EAC1C,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,aAAa,E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CAAwC;IACxC,OAAO;IAEP,gCAAgC;IAChC,IAAI;IAEJ,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,6CAA6C,CAAC,CAAC;YACrF,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,sBAA+B;IAE/B,IAAI,sBAAsB,IAAI,IAAI,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,sBAAgD,CAAC;IAEvE,OAAO,CACL,OAAO,aAAa,CAAC,aAAa,KAAK,UAAU;QACjD,OAAO,aAAa,CAAC,cAAc,KAAK,QAAQ;QAChD,OAAO,aAAa,CAAC,WAAW,KAAK,QAAQ,CAC9C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type Long from \"long\";\nimport { MessageSender } from \"./core/messageSender.js\";\nimport type { ServiceBusMessage } from \"./serviceBusMessage.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport {\n errorInvalidMessageTypeSingleOrArray,\n getSenderClosedErrorMsg,\n throwErrorIfConnectionClosed,\n throwIfNotValidServiceBusMessage,\n throwTypeErrorIfNotInstanceOfParameterType,\n throwTypeErrorIfParameterMissing,\n throwTypeErrorIfParameterNotLong,\n} from \"./util/errors.js\";\nimport type { ServiceBusMessageBatch } from \"./serviceBusMessageBatch.js\";\nimport type { CreateMessageBatchOptions } from \"./models.js\";\nimport type { RetryConfig, RetryOptions, AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { RetryOperationType, retry } from \"@azure/core-amqp\";\nimport type { OperationOptionsBase } from \"./modelsToBeSharedWithEventHubs.js\";\nimport type { TracingSpanLink } from \"@azure/core-tracing\";\nimport { senderLogger as logger } from \"./log.js\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing.js\";\nimport { ensureValidIdentifier } from \"./util/utils.js\";\nimport { ServiceBusError } from \"./serviceBusError.js\";\nimport { instrumentMessage } from \"./diagnostics/instrumentServiceBusMessage.js\";\n\n/**\n * A Sender can be used to send messages, schedule messages to be sent at a later time\n * and cancel such scheduled messages.\n * Use the `createSender` function on the ServiceBusClient to instantiate a Sender.\n * The Sender class is an abstraction over the underlying AMQP sender link.\n */\nexport interface ServiceBusSender {\n /**\n * A name used to identify the sender. This can be used to correlate logs and exceptions.\n * If not specified or empty, a random unique one will be generated.\n */\n identifier: string;\n /**\n * Sends the given messages after creating an AMQP Sender link if it doesn't already exist.\n *\n * - To send messages to a `session` and/or `partition` enabled Queue/Topic, set the `sessionId`\n * and/or `partitionKey` properties respectively on the messages.\n * - All messages passed to the same sendMessages() call should have the same `sessionId` (if using\n * sessions) and the same `partitionKey` (if using partitions).\n *\n * **Note:**\n *\n * __If you want to send messages of size greater than 1MB, please send individual messages instead of sending a batched message or an array of messages like below.__\n *\n * `await sender.sendMessages(message);`\n *\n * __This is because the batched messages are not capable of sending the larger messages yet. You'll hit the `force detached` error in this case otherwise. Read [service-bus-premium-messaging#large-messages-support](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support). More info at [#23014](https://github.com/Azure/azure-sdk-for-js/pull/23014).__\n *\n * @param messages - A single message or an array of messages or a batch of messages created via the createBatch()\n * method to send.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws `ServiceBusError` with the code `MessageSizeExceeded` if the provided messages do not fit in a single `ServiceBusMessageBatch`.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while sending messages to the service.\n */\n sendMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | ServiceBusMessageBatch\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n options?: OperationOptionsBase,\n ): Promise<void>;\n\n /**\n * Creates an instance of `ServiceBusMessageBatch` to which one can add messages until the maximum supported size is reached.\n * The batch can be passed to the {@link send} method to send the messages to Azure Service Bus.\n * @param options - Configures the behavior of the batch.\n * - `maxSizeInBytes`: The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.\n *\n * @throws `ServiceBusError` if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n createMessageBatch(options?: CreateMessageBatchOptions): Promise<ServiceBusMessageBatch>;\n\n // TODO: Commented out to come up with an alternative name\n // /**\n // * Opens the AMQP link to Azure Service Bus from the sender.\n // *\n // * It is not necessary to call this method in order to use the sender. It is\n // * recommended to call this before your first sendMessages() call if you\n // * want to front load the work of setting up the AMQP link to the service.\n // *\n // * @param options - Options to configure tracing and the abortSignal.\n // */\n // open(options?: OperationOptionsBase): Promise<void>;\n\n /**\n * Returns `true` if either the sender or the client that created it has been closed.\n * @readonly\n */\n isClosed: boolean;\n\n /**\n * Schedules given messages to appear on Service Bus Queue/Subscription at a later time.\n *\n * @param messages - Message or an array of messages that need to be scheduled.\n * @param scheduledEnqueueTimeUtc - The UTC time at which the messages should be enqueued.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns The sequence numbers of messages that were scheduled.\n * You will need the sequence number if you intend to cancel the scheduling of the messages.\n * Save the `Long` type as-is in your application without converting to number. Since JavaScript\n * only supports 53 bit numbers, converting the `Long` to number will cause loss in precision.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while scheduling messages.\n */\n scheduleMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n scheduledEnqueueTimeUtc: Date,\n options?: OperationOptionsBase,\n ): Promise<Long[]>;\n\n /**\n * Cancels multiple messages that were scheduled to appear on a ServiceBus Queue/Subscription.\n * @param sequenceNumbers - Sequence number or an array of sequence numbers of the messages to be cancelled.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while canceling scheduled messages.\n */\n cancelScheduledMessages(\n sequenceNumbers: Long | Long[],\n options?: OperationOptionsBase,\n ): Promise<void>;\n /**\n * Path of the entity for which the sender has been created.\n */\n entityPath: string;\n /**\n * Closes the underlying AMQP sender link.\n * Once closed, the sender cannot be used for any further operations.\n * Use the `createSender` function on the QueueClient or TopicClient to instantiate a new Sender\n *\n */\n close(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusSenderImpl implements ServiceBusSender {\n public identifier: string;\n private _retryOptions: RetryOptions;\n /**\n * Denotes if close() was called on this sender\n */\n private _isClosed: boolean = false;\n private _sender: MessageSender;\n public entityPath: string;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|sender:${this.entityPath}]`;\n }\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 retryOptions: RetryOptions = {},\n identifier?: string,\n ) {\n throwErrorIfConnectionClosed(_context);\n this.entityPath = _entityPath;\n this.identifier = ensureValidIdentifier(this.entityPath, identifier);\n this._sender = MessageSender.create(this.identifier, this._context, _entityPath, retryOptions);\n this._retryOptions = retryOptions;\n }\n\n private _throwIfSenderOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n const errorMessage = getSenderClosedErrorMsg(this._entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `[${this._context.connectionId}] is closed`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n async sendMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | ServiceBusMessageBatch\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n options?: OperationOptionsBase,\n ): Promise<void> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"messages\", messages);\n\n if (!isServiceBusMessageBatch(messages) && !Array.isArray(messages)) {\n // Case 1: Single message\n throwIfNotValidServiceBusMessage(messages, errorInvalidMessageTypeSingleOrArray);\n const originalMessage = messages as ServiceBusMessage | AmqpAnnotatedMessage;\n const { message, spanContext } = instrumentMessage(\n originalMessage,\n options ?? {},\n this.entityPath,\n this._context.config.host,\n \"publish\",\n );\n const spanLinks: TracingSpanLink[] = spanContext ? [{ tracingContext: spanContext }] : [];\n return tracingClient.withSpan(\n \"ServiceBusSender.send\",\n options ?? {},\n (updatedOptions) => this._sender.send(message, updatedOptions),\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"publish\",\n \"client\",\n ),\n },\n );\n }\n\n let batch: ServiceBusMessageBatch;\n if (isServiceBusMessageBatch(messages)) {\n // Case 2: Batch message\n batch = messages;\n } else {\n // Case 3: Array of messages\n batch = await this.createMessageBatch(options);\n for (const message of messages) {\n throwIfNotValidServiceBusMessage(message, errorInvalidMessageTypeSingleOrArray);\n if (!batch.tryAddMessage(message, options)) {\n // this is too big - throw an error\n throw new ServiceBusError(\n \"Messages were too big to fit in a single batch. Remove some messages and try again or create your own batch using createBatch(), which gives more fine-grained control.\",\n \"MessageSizeExceeded\",\n );\n }\n }\n }\n\n const spanLinks: TracingSpanLink[] = batch._messageSpanContexts.map((tracingContext) => {\n return {\n tracingContext,\n };\n });\n\n return tracingClient.withSpan(\n \"ServiceBusSender.send\",\n options ?? {},\n (updatedOptions) => this._sender.sendBatch(batch, updatedOptions),\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"publish\",\n \"client\",\n ),\n },\n );\n }\n\n async createMessageBatch(options?: CreateMessageBatchOptions): Promise<ServiceBusMessageBatch> {\n this._throwIfSenderOrConnectionClosed();\n return this._sender.createBatch(options);\n }\n\n async scheduleMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n scheduledEnqueueTimeUtc: Date,\n options: OperationOptionsBase = {},\n ): Promise<Long[]> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"scheduledEnqueueTimeUtc\",\n scheduledEnqueueTimeUtc,\n );\n throwTypeErrorIfNotInstanceOfParameterType(\n this._context.connectionId,\n \"scheduledEnqueueTimeUtc\",\n scheduledEnqueueTimeUtc,\n Date,\n );\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"messages\", messages);\n const messagesToSchedule = Array.isArray(messages) ? messages : [messages];\n\n for (const message of messagesToSchedule) {\n throwIfNotValidServiceBusMessage(message, errorInvalidMessageTypeSingleOrArray);\n }\n\n const scheduleMessageOperationPromise = async (): Promise<Long[]> => {\n return this._context\n .getManagementClient(this._entityPath)\n .scheduleMessages(scheduledEnqueueTimeUtc, messagesToSchedule, {\n ...options,\n associatedLinkName: this._sender.name,\n requestName: \"scheduleMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<Long[]> = {\n operation: scheduleMessageOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<Long[]>(config);\n }\n\n async cancelScheduledMessages(\n sequenceNumbers: Long | Long[],\n options: OperationOptionsBase = {},\n ): Promise<void> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n throwTypeErrorIfParameterNotLong(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n\n const sequenceNumbersToCancel = Array.isArray(sequenceNumbers)\n ? sequenceNumbers\n : [sequenceNumbers];\n const cancelSchedulesMessagesOperationPromise = async (): Promise<void> => {\n return this._context\n .getManagementClient(this._entityPath)\n .cancelScheduledMessages(sequenceNumbersToCancel, {\n ...options,\n associatedLinkName: this._sender.name,\n requestName: \"cancelScheduledMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<void> = {\n operation: cancelSchedulesMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<void>(config);\n }\n\n // async open(options?: OperationOptionsBase): Promise<void> {\n // this._throwIfSenderOrConnectionClosed();\n\n // const config: RetryConfig<void> = {\n // // TODO: Pass tracing options too\n // operation: () => this._sender.open(undefined, options?.abortSignal),\n // connectionId: this._context.connectionId,\n // operationType: RetryOperationType.senderLink,\n // retryOptions: this._retryOptions,\n // abortSignal: options?.abortSignal\n // };\n\n // return retry<void>(config);\n // }\n\n async close(): Promise<void> {\n try {\n this._isClosed = true;\n await this._sender.close();\n } catch (err: any) {\n logger.logError(err, `${this.logPrefix} An error occurred while closing the Sender`);\n throw err;\n }\n }\n}\n\n/**\n * @internal\n */\nexport function isServiceBusMessageBatch(\n messageBatchOrAnything: unknown,\n): messageBatchOrAnything is ServiceBusMessageBatch {\n if (messageBatchOrAnything == null) {\n return false;\n }\n\n const possibleBatch = messageBatchOrAnything as ServiceBusMessageBatch;\n\n return (\n typeof possibleBatch.tryAddMessage === \"function\" &&\n typeof possibleBatch.maxSizeInBytes === \"number\" &&\n typeof possibleBatch.sizeInBytes === \"number\"\n );\n}\n"]}
1
+ {"version":3,"file":"sender.js","sourceRoot":"","sources":["../../src/sender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,0CAA0C,EAC1C,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,kBAAkB,CAAC;AAI1B,O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CAAC;IAC7B,CAAC;IAED,8DAA8D;IAC9D,6CAA6C;IAE7C,wCAAwC;IACxC,wCAAwC;IACxC,2EAA2E;IAC3E,gDAAgD;IAChD,oDAAoD;IACpD,wCAAwC;IACxC,wCAAwC;IACxC,OAAO;IAEP,gCAAgC;IAChC,IAAI;IAEJ,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,6CAA6C,CAAC,CAAC;YACrF,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,sBAA+B;IAE/B,IAAI,sBAAsB,IAAI,IAAI,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,sBAAgD,CAAC;IAEvE,OAAO,CACL,OAAO,aAAa,CAAC,aAAa,KAAK,UAAU;QACjD,OAAO,aAAa,CAAC,cAAc,KAAK,QAAQ;QAChD,OAAO,aAAa,CAAC,WAAW,KAAK,QAAQ,CAC9C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type Long from \"long\";\nimport { MessageSender } from \"./core/messageSender.js\";\nimport type { ServiceBusMessage } from \"./serviceBusMessage.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport {\n errorInvalidMessageTypeSingleOrArray,\n getSenderClosedErrorMsg,\n throwErrorIfConnectionClosed,\n throwIfNotValidServiceBusMessage,\n throwTypeErrorIfNotInstanceOfParameterType,\n throwTypeErrorIfParameterMissing,\n throwTypeErrorIfParameterNotLong,\n} from \"./util/errors.js\";\nimport type { ServiceBusMessageBatch } from \"./serviceBusMessageBatch.js\";\nimport type { CreateMessageBatchOptions } from \"./models.js\";\nimport type { RetryConfig, RetryOptions, AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { RetryOperationType, retry } from \"@azure/core-amqp\";\nimport type { OperationOptionsBase } from \"./modelsToBeSharedWithEventHubs.js\";\nimport type { TracingSpanLink } from \"@azure/core-tracing\";\nimport { senderLogger as logger } from \"./log.js\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing.js\";\nimport { ensureValidIdentifier } from \"./util/utils.js\";\nimport { ServiceBusError } from \"./serviceBusError.js\";\nimport { instrumentMessage } from \"./diagnostics/instrumentServiceBusMessage.js\";\n\n/**\n * A Sender can be used to send messages, schedule messages to be sent at a later time\n * and cancel such scheduled messages.\n * Use the `createSender` function on the ServiceBusClient to instantiate a Sender.\n * The Sender class is an abstraction over the underlying AMQP sender link.\n */\nexport interface ServiceBusSender {\n /**\n * A name used to identify the sender. This can be used to correlate logs and exceptions.\n * If not specified or empty, a random unique one will be generated.\n */\n identifier: string;\n /**\n * Sends the given messages after creating an AMQP Sender link if it doesn't already exist.\n *\n * - To send messages to a `session` and/or `partition` enabled Queue/Topic, set the `sessionId`\n * and/or `partitionKey` properties respectively on the messages.\n * - All messages passed to the same sendMessages() call should have the same `sessionId` (if using\n * sessions) and the same `partitionKey` (if using partitions).\n *\n * **Note:**\n *\n * __If you want to send messages of size greater than 1MB, please send individual messages instead of sending a batched message or an array of messages like below.__\n *\n * `await sender.sendMessages(message);`\n *\n * __This is because the batched messages are not capable of sending the larger messages yet. You'll hit the `force detached` error in this case otherwise. Read [service-bus-premium-messaging#large-messages-support](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support). More info at [#23014](https://github.com/Azure/azure-sdk-for-js/pull/23014).__\n *\n * @param messages - A single message or an array of messages or a batch of messages created via the createBatch()\n * method to send.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws `ServiceBusError` with the code `MessageSizeExceeded` if the provided messages do not fit in a single `ServiceBusMessageBatch`.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while sending messages to the service.\n */\n sendMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | ServiceBusMessageBatch\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n options?: OperationOptionsBase,\n ): Promise<void>;\n\n /**\n * Creates an instance of `ServiceBusMessageBatch` to which one can add messages until the maximum supported size is reached.\n * The batch can be passed to the {@link send} method to send the messages to Azure Service Bus.\n * @param options - Configures the behavior of the batch.\n * - `maxSizeInBytes`: The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.\n *\n * @throws `ServiceBusError` if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n createMessageBatch(options?: CreateMessageBatchOptions): Promise<ServiceBusMessageBatch>;\n\n // TODO: Commented out to come up with an alternative name\n // /**\n // * Opens the AMQP link to Azure Service Bus from the sender.\n // *\n // * It is not necessary to call this method in order to use the sender. It is\n // * recommended to call this before your first sendMessages() call if you\n // * want to front load the work of setting up the AMQP link to the service.\n // *\n // * @param options - Options to configure tracing and the abortSignal.\n // */\n // open(options?: OperationOptionsBase): Promise<void>;\n\n /**\n * Returns `true` if either the sender or the client that created it has been closed.\n * @readonly\n */\n isClosed: boolean;\n\n /**\n * Schedules given messages to appear on Service Bus Queue/Subscription at a later time.\n *\n * @param messages - Message or an array of messages that need to be scheduled.\n * @param scheduledEnqueueTimeUtc - The UTC time at which the messages should be enqueued.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns The sequence numbers of messages that were scheduled.\n * You will need the sequence number if you intend to cancel the scheduling of the messages.\n * Save the `Long` type as-is in your application without converting to number. Since JavaScript\n * only supports 53 bit numbers, converting the `Long` to number will cause loss in precision.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while scheduling messages.\n */\n scheduleMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n scheduledEnqueueTimeUtc: Date,\n options?: OperationOptionsBase,\n ): Promise<Long[]>;\n\n /**\n * Cancels multiple messages that were scheduled to appear on a ServiceBus Queue/Subscription.\n * @param sequenceNumbers - Sequence number or an array of sequence numbers of the messages to be cancelled.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while canceling scheduled messages.\n */\n cancelScheduledMessages(\n sequenceNumbers: Long | Long[],\n options?: OperationOptionsBase,\n ): Promise<void>;\n /**\n * Path of the entity for which the sender has been created.\n */\n entityPath: string;\n /**\n * Closes the underlying AMQP sender link.\n * Once closed, the sender cannot be used for any further operations.\n * Use the `createSender` function on the QueueClient or TopicClient to instantiate a new Sender\n *\n */\n close(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusSenderImpl implements ServiceBusSender {\n public identifier: string;\n private _retryOptions: RetryOptions;\n /**\n * Denotes if close() was called on this sender\n */\n private _isClosed: boolean = false;\n private _sender: MessageSender;\n public entityPath: string;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|sender:${this.entityPath}]`;\n }\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 retryOptions: RetryOptions = {},\n identifier?: string,\n ) {\n throwErrorIfConnectionClosed(_context);\n this.entityPath = _entityPath;\n this.identifier = ensureValidIdentifier(this.entityPath, identifier);\n this._sender = MessageSender.create(this.identifier, this._context, _entityPath, retryOptions);\n this._retryOptions = retryOptions;\n }\n\n private _throwIfSenderOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n const errorMessage = getSenderClosedErrorMsg(this._entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `[${this._context.connectionId}] is closed`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n async sendMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | ServiceBusMessageBatch\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n options?: OperationOptionsBase,\n ): Promise<void> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"messages\", messages);\n\n if (!isServiceBusMessageBatch(messages) && !Array.isArray(messages)) {\n // Case 1: Single message\n throwIfNotValidServiceBusMessage(messages, errorInvalidMessageTypeSingleOrArray);\n const originalMessage = messages as ServiceBusMessage | AmqpAnnotatedMessage;\n const { message, spanContext } = instrumentMessage(\n originalMessage,\n options ?? {},\n this.entityPath,\n this._context.config.host,\n \"publish\",\n );\n const spanLinks: TracingSpanLink[] = spanContext ? [{ tracingContext: spanContext }] : [];\n return tracingClient.withSpan(\n \"ServiceBusSender.send\",\n options ?? {},\n (updatedOptions) => this._sender.send(message, updatedOptions),\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"publish\",\n \"client\",\n ),\n },\n );\n }\n\n let batch: ServiceBusMessageBatch;\n if (isServiceBusMessageBatch(messages)) {\n // Case 2: Batch message\n batch = messages;\n } else {\n // Case 3: Array of messages\n batch = await this.createMessageBatch(options);\n for (const message of messages) {\n throwIfNotValidServiceBusMessage(message, errorInvalidMessageTypeSingleOrArray);\n if (!batch.tryAddMessage(message, options)) {\n // this is too big - throw an error\n throw new ServiceBusError(\n \"Messages were too big to fit in a single batch. Remove some messages and try again or create your own batch using createBatch(), which gives more fine-grained control.\",\n \"MessageSizeExceeded\",\n );\n }\n }\n }\n\n const spanLinks: TracingSpanLink[] = batch._messageSpanContexts.map((tracingContext) => {\n return {\n tracingContext,\n };\n });\n\n return tracingClient.withSpan(\n \"ServiceBusSender.send\",\n options ?? {},\n (updatedOptions) => this._sender.sendBatch(batch, updatedOptions),\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"publish\",\n \"client\",\n ),\n },\n );\n }\n\n async createMessageBatch(options?: CreateMessageBatchOptions): Promise<ServiceBusMessageBatch> {\n this._throwIfSenderOrConnectionClosed();\n return this._sender.createBatch(options);\n }\n\n async scheduleMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n scheduledEnqueueTimeUtc: Date,\n options: OperationOptionsBase = {},\n ): Promise<Long[]> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"scheduledEnqueueTimeUtc\",\n scheduledEnqueueTimeUtc,\n );\n throwTypeErrorIfNotInstanceOfParameterType(\n this._context.connectionId,\n \"scheduledEnqueueTimeUtc\",\n scheduledEnqueueTimeUtc,\n Date,\n );\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"messages\", messages);\n const messagesToSchedule = Array.isArray(messages) ? messages : [messages];\n\n for (const message of messagesToSchedule) {\n throwIfNotValidServiceBusMessage(message, errorInvalidMessageTypeSingleOrArray);\n }\n\n const scheduleMessageOperationPromise = async (): Promise<Long[]> => {\n return this._context\n .getManagementClient(this._entityPath)\n .scheduleMessages(scheduledEnqueueTimeUtc, messagesToSchedule, {\n ...options,\n associatedLinkName: this._sender.name,\n requestName: \"scheduleMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<Long[]> = {\n operation: scheduleMessageOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<Long[]>(config);\n }\n\n async cancelScheduledMessages(\n sequenceNumbers: Long | Long[],\n options: OperationOptionsBase = {},\n ): Promise<void> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n throwTypeErrorIfParameterNotLong(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n\n const sequenceNumbersToCancel = Array.isArray(sequenceNumbers)\n ? sequenceNumbers\n : [sequenceNumbers];\n const cancelSchedulesMessagesOperationPromise = async (): Promise<void> => {\n return this._context\n .getManagementClient(this._entityPath)\n .cancelScheduledMessages(sequenceNumbersToCancel, {\n ...options,\n associatedLinkName: this._sender.name,\n requestName: \"cancelScheduledMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<void> = {\n operation: cancelSchedulesMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<void>(config);\n }\n\n // async open(options?: OperationOptionsBase): Promise<void> {\n // this._throwIfSenderOrConnectionClosed();\n\n // const config: RetryConfig<void> = {\n // // TODO: Pass tracing options too\n // operation: () => this._sender.open(undefined, options?.abortSignal),\n // connectionId: this._context.connectionId,\n // operationType: RetryOperationType.senderLink,\n // retryOptions: this._retryOptions,\n // abortSignal: options?.abortSignal\n // };\n\n // return retry<void>(config);\n // }\n\n async close(): Promise<void> {\n try {\n this._isClosed = true;\n await this._sender.close();\n } catch (err: any) {\n logger.logError(err, `${this.logPrefix} An error occurred while closing the Sender`);\n throw err;\n }\n }\n}\n\n/**\n * @internal\n */\nexport function isServiceBusMessageBatch(\n messageBatchOrAnything: unknown,\n): messageBatchOrAnything is ServiceBusMessageBatch {\n if (messageBatchOrAnything == null) {\n return false;\n }\n\n const possibleBatch = messageBatchOrAnything as ServiceBusMessageBatch;\n\n return (\n typeof possibleBatch.tryAddMessage === \"function\" &&\n typeof possibleBatch.maxSizeInBytes === \"number\" &&\n typeof possibleBatch.sizeInBytes === \"number\"\n );\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure/service-bus",
3
3
  "sdk-type": "client",
4
4
  "author": "Microsoft Corporation",
5
- "version": "7.10.0-alpha.20250606.1",
5
+ "version": "7.10.0-alpha.20250613.2",
6
6
  "license": "MIT",
7
7
  "description": "Azure Service Bus SDK for JavaScript",
8
8
  "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/servicebus/service-bus/",