@azure/service-bus 7.10.0-alpha.20250107.2 → 7.10.0-alpha.20250109.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/core/managementClient.js +1 -1
- package/dist/browser/core/managementClient.js.map +1 -1
- package/dist/browser/models.d.ts +4 -4
- package/dist/browser/models.js.map +1 -1
- package/dist/browser/receivers/sessionReceiver.d.ts +4 -4
- package/dist/browser/receivers/sessionReceiver.js +2 -2
- package/dist/browser/receivers/sessionReceiver.js.map +1 -1
- package/dist/browser/sender.d.ts +1 -1
- package/dist/browser/sender.js.map +1 -1
- package/dist/browser/serviceBusClient.d.ts +8 -8
- package/dist/browser/serviceBusClient.js.map +1 -1
- package/dist/browser/serviceBusMessage.d.ts +19 -19
- package/dist/browser/serviceBusMessage.js.map +1 -1
- package/dist/browser/util/constants.d.ts +1 -1
- package/dist/browser/util/constants.js +1 -1
- package/dist/browser/util/constants.js.map +1 -1
- package/dist/commonjs/core/managementClient.js +1 -1
- package/dist/commonjs/core/managementClient.js.map +1 -1
- package/dist/commonjs/models.d.ts +4 -4
- package/dist/commonjs/models.js.map +1 -1
- package/dist/commonjs/receivers/sessionReceiver.d.ts +4 -4
- package/dist/commonjs/receivers/sessionReceiver.js +2 -2
- package/dist/commonjs/receivers/sessionReceiver.js.map +1 -1
- package/dist/commonjs/sender.d.ts +1 -1
- package/dist/commonjs/sender.js.map +1 -1
- package/dist/commonjs/serviceBusClient.d.ts +8 -8
- package/dist/commonjs/serviceBusClient.js.map +1 -1
- package/dist/commonjs/serviceBusMessage.d.ts +19 -19
- package/dist/commonjs/serviceBusMessage.js.map +1 -1
- package/dist/commonjs/util/constants.d.ts +1 -1
- package/dist/commonjs/util/constants.js +1 -1
- package/dist/commonjs/util/constants.js.map +1 -1
- package/dist/esm/core/managementClient.js +1 -1
- package/dist/esm/core/managementClient.js.map +1 -1
- package/dist/esm/models.d.ts +4 -4
- package/dist/esm/models.js.map +1 -1
- package/dist/esm/receivers/sessionReceiver.d.ts +4 -4
- package/dist/esm/receivers/sessionReceiver.js +2 -2
- package/dist/esm/receivers/sessionReceiver.js.map +1 -1
- package/dist/esm/sender.d.ts +1 -1
- package/dist/esm/sender.js.map +1 -1
- package/dist/esm/serviceBusClient.d.ts +8 -8
- package/dist/esm/serviceBusClient.js.map +1 -1
- package/dist/esm/serviceBusMessage.d.ts +19 -19
- package/dist/esm/serviceBusMessage.js.map +1 -1
- package/dist/esm/util/constants.d.ts +1 -1
- package/dist/esm/util/constants.js +1 -1
- package/dist/esm/util/constants.js.map +1 -1
- package/dist/react-native/core/managementClient.js +1 -1
- package/dist/react-native/core/managementClient.js.map +1 -1
- package/dist/react-native/models.d.ts +4 -4
- package/dist/react-native/models.js.map +1 -1
- package/dist/react-native/receivers/sessionReceiver.d.ts +4 -4
- package/dist/react-native/receivers/sessionReceiver.js +2 -2
- package/dist/react-native/receivers/sessionReceiver.js.map +1 -1
- package/dist/react-native/sender.d.ts +1 -1
- package/dist/react-native/sender.js.map +1 -1
- package/dist/react-native/serviceBusClient.d.ts +8 -8
- package/dist/react-native/serviceBusClient.js.map +1 -1
- package/dist/react-native/serviceBusMessage.d.ts +19 -19
- package/dist/react-native/serviceBusMessage.js.map +1 -1
- package/dist/react-native/util/constants.d.ts +1 -1
- package/dist/react-native/util/constants.js +1 -1
- package/dist/react-native/util/constants.js.map +1 -1
- package/package.json +2 -2
|
@@ -120,7 +120,7 @@ class ServiceBusSessionReceiverImpl {
|
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Sets the state on the Session. For more on session states, see
|
|
123
|
-
* {@link https://
|
|
123
|
+
* {@link https://learn.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}
|
|
124
124
|
* @param state - The state that needs to be set.
|
|
125
125
|
* @param options - Options bag to pass an abort signal or tracing options.
|
|
126
126
|
* @throws Error if the underlying connection or receiver is closed.
|
|
@@ -147,7 +147,7 @@ class ServiceBusSessionReceiverImpl {
|
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Gets the state of the Session. For more on session states, see
|
|
150
|
-
* {@link https://
|
|
150
|
+
* {@link https://learn.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}
|
|
151
151
|
* @param options - Options bag to pass an abort signal or tracing options.
|
|
152
152
|
* @returns The state of that session
|
|
153
153
|
* @throws Error if the underlying connection or receiver is closed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionReceiver.js","sourceRoot":"","sources":["../../../src/receivers/sessionReceiver.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAgBlC,iDAS2B;AAE3B,2DAQ6B;AAE7B,+CAAoG;AAIpG,gDAAkG;AAGlG,kGAAwF;AACxF,0DAA0D;AAC1D,sCAAqD;AACrD,8DAAiE;AAkEjE;;GAEG;AACH,MAAa,6BAA6B;IASxC,IAAY,SAAS;QACnB,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,YAAY,IAAI,CAAC,UAAU,GAAG,CAAC;IACtE,CAAC;IAED;;;;OAIG;IACH,YACU,eAA+B,EAC/B,QAA2B,EAC5B,UAAkB,EAClB,WAA4C,EAC3C,sBAA+B,EAC/B,mBAA4B,EAC5B,gBAA8B,EAAE;QANhC,oBAAe,GAAf,eAAe,CAAgB;QAC/B,aAAQ,GAAR,QAAQ,CAAmB;QAC5B,eAAU,GAAV,UAAU,CAAQ;QAClB,gBAAW,GAAX,WAAW,CAAiC;QAC3C,2BAAsB,GAAtB,sBAAsB,CAAS;QAC/B,wBAAmB,GAAnB,mBAAmB,CAAS;QAC5B,kBAAa,GAAb,aAAa,CAAmB;QArB1C;;WAEG;QACK,cAAS,GAAY,KAAK,CAAC;QAoBjC,IAAA,wCAA4B,EAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,eAA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,IAAA,iDAAqC,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC7F,MAAM,OAAO,GAAG,OAAgC,CAAC;QACjD,OAAO,IAAA,qCAAiB,EAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QACrC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,uBAAM,CAAC,QAAQ,CACb,GAAG,EACH,uEAAuE,EACvE,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,SAAS,CACf,CAAC;YACF,MAAM,GAAG,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;IAED;;;OAGG;IACK,oBAAoB;QAC1B,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;IACjF,CAAC;CACF;AAriBD,sEAqiBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectionContext } from \"../connectionContext.js\";\nimport type {\n MessageHandlers,\n ReceiveMessagesOptions,\n ServiceBusReceivedMessage,\n} from \"../index.js\";\nimport type {\n PeekMessagesOptions,\n GetMessageIteratorOptions,\n SubscribeOptions,\n DeleteMessagesOptions,\n PurgeMessagesOptions,\n} from \"../models.js\";\nimport type { MessageSession } from \"../session/messageSession.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 { OnError, OnMessage } from \"../core/messageReceiver.js\";\nimport {\n abandonMessage,\n assertValidMessageHandlers,\n completeMessage,\n deadLetterMessage,\n deferMessage,\n getMessageIterator,\n wrapProcessErrorHandler,\n} from \"./receiverCommon.js\";\nimport type { ServiceBusReceiver } from \"./receiver.js\";\nimport { defaultMaxTimeAfterFirstMessageForBatchingMs, MaxDeleteMessageCount } from \"./receiver.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, ErrorNameConditionMapper } from \"@azure/core-amqp\";\nimport type { OperationOptionsBase } from \"../modelsToBeSharedWithEventHubs.js\";\nimport type { AmqpError } from \"rhea-promise\";\nimport { toProcessingSpanOptions } from \"../diagnostics/instrumentServiceBusMessage.js\";\nimport { tracingClient } from \"../diagnostics/tracing.js\";\nimport { receiverLogger as logger } from \"../log.js\";\nimport { translateServiceBusError } from \"../serviceBusError.js\";\n\n/**\n *A receiver that handles sessions, including renewing the session lock.\n */\nexport interface ServiceBusSessionReceiver extends ServiceBusReceiver {\n /**\n * The session ID.\n */\n readonly sessionId: string;\n\n /**\n * The time in UTC until which the session is locked.\n * Every time `renewSessionLock()` is called, this time gets updated to current time plus the lock\n * duration as specified during the Queue/Subscription creation.\n *\n * Will return undefined until a AMQP receiver link has been successfully set up for the session.\n *\n * @readonly\n */\n readonly sessionLockedUntilUtc: Date;\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 * Renews the lock on the session.\n */\n renewSessionLock(options?: OperationOptionsBase): Promise<Date>;\n\n /**\n * Gets the state of the Session. For more on session states, see\n * {@link https://docs.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns The state of that session\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while retrieving session state.\n */\n getSessionState(options?: OperationOptionsBase): Promise<any>;\n\n /**\n * Sets the state on the Session. For more on session states, see\n * {@link https://docs.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}\n * @param state - The state that needs to be set.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while setting the session state.\n *\n */\n setSessionState(state: any, options?: OperationOptionsBase): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusSessionReceiverImpl implements ServiceBusSessionReceiver {\n public sessionId: string;\n public identifier: string;\n\n /**\n * Denotes if close() was called on this receiver\n */\n private _isClosed: boolean = false;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|session:${this.entityPath}]`;\n }\n\n /**\n * @internal\n * @throws Error if the underlying connection is closed.\n * @throws Error if an open receiver is already existing for given sessionId.\n */\n constructor(\n private _messageSession: MessageSession,\n private _context: ConnectionContext,\n public entityPath: string,\n public receiveMode: \"peekLock\" | \"receiveAndDelete\",\n private _skipParsingBodyAsJson: boolean,\n private _skipConvertingDate: boolean,\n private _retryOptions: RetryOptions = {},\n ) {\n throwErrorIfConnectionClosed(_context);\n this.sessionId = _messageSession.sessionId;\n this.identifier = _messageSession.identifier;\n }\n\n private _throwIfReceiverOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n if (this._isClosed) {\n const errorMessage = getReceiverClosedErrorMsg(this.entityPath, this.sessionId);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} already closed`);\n throw error;\n }\n const amqpError: AmqpError = {\n condition: ErrorNameConditionMapper.SessionLockLostError,\n description: `The session lock has expired on the session with id ${this.sessionId}`,\n };\n throw translateServiceBusError(amqpError);\n }\n }\n\n private _throwIfAlreadyReceiving(): void {\n if (this._isReceivingMessages()) {\n const errorMessage = getAlreadyReceivingErrorMsg(this.entityPath, this.sessionId);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is already receiving.`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return (\n this._isClosed ||\n !this._context.messageSessions[this._messageSession.name] ||\n !this._messageSession.isOpen()\n );\n }\n\n /**\n * The time in UTC until which the session is locked.\n * Every time `renewSessionLock()` is called, this time gets updated to current time plus the lock\n * duration as specified during the Queue/Subscription creation.\n *\n * When the lock on the session expires\n * - The current receiver can no longer be used to receive more messages.\n * Create a new receiver using `ServiceBusClient.acceptSession()` or `ServiceBusClient.acceptNextSession()`.\n * - Messages that were received in `peekLock` mode with this receiver but not yet settled\n * will land back in the Queue/Subscription with their delivery count incremented.\n *\n * @readonly\n */\n public get sessionLockedUntilUtc(): Date {\n return this._messageSession.sessionLockedUntilUtc;\n }\n\n /**\n * Renews the lock on the session for the duration as specified during the Queue/Subscription\n * creation. You can check the `sessionLockedUntilUtc` property for the time when the lock expires.\n *\n * When the lock on the session expires\n * - The current receiver can no longer be used to receive mode messages.\n * Create a new receiver using `ServiceBusClient.acceptSession()` or `ServiceBusClient.acceptNextSession()`.\n * - Messages that were received in `peekLock` mode with this receiver but not yet settled\n * will land back in the Queue/Subscription with their delivery count incremented.\n *\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns New lock token expiry date and time in UTC format.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while renewing session lock.\n */\n async renewSessionLock(options?: OperationOptionsBase): Promise<Date> {\n this._throwIfReceiverOrConnectionClosed();\n\n return tracingClient.withSpan(\n \"ServiceBusSessionReceiver.renewSessionLock\",\n options ?? {},\n (updatedOptions) => {\n const renewSessionLockOperationPromise = async (): Promise<Date> => {\n this._messageSession!.sessionLockedUntilUtc = await this._context\n .getManagementClient(this.entityPath)\n .renewSessionLock(this.sessionId, {\n ...updatedOptions,\n associatedLinkName: this._messageSession.name,\n requestName: \"renewSessionLock\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n return this._messageSession!.sessionLockedUntilUtc!;\n };\n const config: RetryConfig<Date> = {\n operation: renewSessionLockOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<Date>(config);\n },\n );\n }\n\n /**\n * Sets the state on the Session. For more on session states, see\n * {@link https://docs.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}\n * @param state - The state that needs to be set.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while setting the session state.\n */\n async setSessionState(state: unknown, options: OperationOptionsBase = {}): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n\n return tracingClient.withSpan(\n \"ServiceBusSessionReceiver.setSessionState\",\n options ?? {},\n (updatedOptions) => {\n const setSessionStateOperationPromise = async (): Promise<void> => {\n await this._context\n .getManagementClient(this.entityPath)\n .setSessionState(this.sessionId!, state, {\n ...updatedOptions,\n associatedLinkName: this._messageSession.name,\n requestName: \"setState\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n return;\n };\n const config: RetryConfig<void> = {\n operation: setSessionStateOperationPromise,\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 }\n\n /**\n * Gets the state of the Session. For more on session states, see\n * {@link https://docs.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns The state of that session\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while retrieving session state.\n */\n async getSessionState(options: OperationOptionsBase = {}): Promise<any> {\n this._throwIfReceiverOrConnectionClosed();\n\n return tracingClient.withSpan(\n \"ServiceBusSessionReceiver.getSessionState\",\n options ?? {},\n (updatedOptions) => {\n const getSessionStateOperationPromise = async (): Promise<any> => {\n return this._context\n .getManagementClient(this.entityPath)\n .getSessionState(this.sessionId, {\n ...updatedOptions,\n associatedLinkName: this._messageSession.name,\n requestName: \"getState\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<any> = {\n operation: getSessionStateOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<any>(config);\n },\n );\n }\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._messageSession.name,\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 this.sessionId,\n omitMessageBody,\n managementRequestOptions,\n );\n } else {\n return this._context\n .getManagementClient(this.entityPath)\n .peekMessagesBySession(\n this.sessionId,\n maxMessageCount,\n omitMessageBody,\n managementRequestOptions,\n );\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 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, this.sessionId, {\n ...options,\n associatedLinkName: this._messageSession.name,\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, this.sessionId, {\n ...options,\n associatedLinkName: this._messageSession.name,\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 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 deletedCount += batchCount;\n }\n }\n return deletedCount;\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 receiveBatchOperationPromise = async (): Promise<ServiceBusReceivedMessage[]> => {\n const receivedMessages = await this._messageSession!.receiveMessages(\n maxMessageCount,\n options?.maxWaitTimeInMs ?? Constants.defaultOperationTimeoutInMs,\n defaultMaxTimeAfterFirstMessageForBatchingMs,\n options ?? {},\n );\n\n return receivedMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: receiveBatchOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.receiveMessage,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config).catch((err) => {\n throw translateServiceBusError(err);\n });\n }\n\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n close(): Promise<void>;\n } {\n // TODO - receiverOptions for subscribe??\n assertValidMessageHandlers(handlers);\n\n options = options ?? {};\n\n const processError = wrapProcessErrorHandler(handlers);\n\n this._registerMessageHandler(\n async (message: ServiceBusMessageImpl) => {\n return tracingClient.withSpan(\n \"SessionReceiver.process\",\n options ?? {},\n () => handlers.processMessage(message),\n toProcessingSpanOptions(message, this, this._context.config, \"process\"),\n );\n },\n processError,\n options,\n );\n\n return {\n close: async (): Promise<void> => {\n return this._messageSession?.receiverHelper.suspend();\n },\n };\n }\n\n /**\n * Registers handlers to deal with the incoming stream of messages over an AMQP receiver link\n * from a Queue/Subscription.\n * To stop receiving messages, call `close()` on the SessionReceiver.\n *\n * Throws an error if there is another receive operation in progress on the same receiver. If you\n * are not sure whether there is another receive operation running, check the `isReceivingMessages`\n * property on the receiver.\n *\n * @param onMessage - Handler for processing each incoming message.\n * @param onError - Handler for any error that occurs while receiving or processing messages.\n * @param options - Options to control whether messages should be automatically completed\n * or if the lock on the session should be automatically renewed. You can control the\n * maximum number of messages that should be concurrently processed. You can\n * also provide a timeout in milliseconds to denote the amount of time to wait for a new message\n * before closing the receiver.\n *\n * @throws Error if the underlying connection or receiver is closed.\n * @throws Error if the receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages. These are bubbled up to be handled by user provided `onError` handler.\n */\n private _registerMessageHandler(\n onMessage: OnMessage,\n onError: OnError,\n options: SubscribeOptions,\n ): void {\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n const connId = this._context.connectionId;\n throwTypeErrorIfParameterMissing(connId, \"onMessage\", onMessage);\n throwTypeErrorIfParameterMissing(connId, \"onError\", onError);\n if (typeof onMessage !== \"function\") {\n throw new TypeError(\"The parameter 'onMessage' must be of type 'function'.\");\n }\n if (typeof onError !== \"function\") {\n throw new TypeError(\"The parameter 'onError' must be of type 'function'.\");\n }\n\n try {\n this._messageSession.subscribe(onMessage, onError, options);\n } catch (err: any) {\n onError({\n error: err,\n errorSource: \"receive\",\n entityPath: this.entityPath,\n fullyQualifiedNamespace: this._context.config.host,\n identifier: this.identifier,\n });\n }\n }\n\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage> {\n return getMessageIterator(this, options);\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(): Promise<Date> {\n throw new Error(\"Renewing message lock is an invalid operation when working with sessions.\");\n }\n\n async close(): Promise<void> {\n try {\n await this._messageSession.close();\n } catch (err: any) {\n logger.logError(\n err,\n \"%s An error occurred while closing the SessionReceiver for session %s\",\n this.logPrefix,\n this.sessionId,\n );\n throw err;\n } finally {\n this._isClosed = true;\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 return this._messageSession ? this._messageSession.isReceivingMessages : false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sessionReceiver.js","sourceRoot":"","sources":["../../../src/receivers/sessionReceiver.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAgBlC,iDAS2B;AAE3B,2DAQ6B;AAE7B,+CAAoG;AAIpG,gDAAkG;AAGlG,kGAAwF;AACxF,0DAA0D;AAC1D,sCAAqD;AACrD,8DAAiE;AAkEjE;;GAEG;AACH,MAAa,6BAA6B;IASxC,IAAY,SAAS;QACnB,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,YAAY,IAAI,CAAC,UAAU,GAAG,CAAC;IACtE,CAAC;IAED;;;;OAIG;IACH,YACU,eAA+B,EAC/B,QAA2B,EAC5B,UAAkB,EAClB,WAA4C,EAC3C,sBAA+B,EAC/B,mBAA4B,EAC5B,gBAA8B,EAAE;QANhC,oBAAe,GAAf,eAAe,CAAgB;QAC/B,aAAQ,GAAR,QAAQ,CAAmB;QAC5B,eAAU,GAAV,UAAU,CAAQ;QAClB,gBAAW,GAAX,WAAW,CAAiC;QAC3C,2BAAsB,GAAtB,sBAAsB,CAAS;QAC/B,wBAAmB,GAAnB,mBAAmB,CAAS;QAC5B,kBAAa,GAAb,aAAa,CAAmB;QArB1C;;WAEG;QACK,cAAS,GAAY,KAAK,CAAC;QAoBjC,IAAA,wCAA4B,EAAC,QAAQ,CAAC,CAAC;QAC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,CAAC,iBAAiB,CACrB,OAAkC,EAClC,OAAwF;QAExF,IAAI,CAAC,kCAAkC,EAAE,CAAC;QAC1C,IAAA,iDAAqC,EAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC7F,MAAM,OAAO,GAAG,OAAgC,CAAC;QACjD,OAAO,IAAA,qCAAiB,EAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACjG,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;QACrC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,uBAAM,CAAC,QAAQ,CACb,GAAG,EACH,uEAAuE,EACvE,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,SAAS,CACf,CAAC;YACF,MAAM,GAAG,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;IAED;;;OAGG;IACK,oBAAoB;QAC1B,OAAO,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC;IACjF,CAAC;CACF;AAriBD,sEAqiBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectionContext } from \"../connectionContext.js\";\nimport type {\n MessageHandlers,\n ReceiveMessagesOptions,\n ServiceBusReceivedMessage,\n} from \"../index.js\";\nimport type {\n PeekMessagesOptions,\n GetMessageIteratorOptions,\n SubscribeOptions,\n DeleteMessagesOptions,\n PurgeMessagesOptions,\n} from \"../models.js\";\nimport type { MessageSession } from \"../session/messageSession.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 { OnError, OnMessage } from \"../core/messageReceiver.js\";\nimport {\n abandonMessage,\n assertValidMessageHandlers,\n completeMessage,\n deadLetterMessage,\n deferMessage,\n getMessageIterator,\n wrapProcessErrorHandler,\n} from \"./receiverCommon.js\";\nimport type { ServiceBusReceiver } from \"./receiver.js\";\nimport { defaultMaxTimeAfterFirstMessageForBatchingMs, MaxDeleteMessageCount } from \"./receiver.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, ErrorNameConditionMapper } from \"@azure/core-amqp\";\nimport type { OperationOptionsBase } from \"../modelsToBeSharedWithEventHubs.js\";\nimport type { AmqpError } from \"rhea-promise\";\nimport { toProcessingSpanOptions } from \"../diagnostics/instrumentServiceBusMessage.js\";\nimport { tracingClient } from \"../diagnostics/tracing.js\";\nimport { receiverLogger as logger } from \"../log.js\";\nimport { translateServiceBusError } from \"../serviceBusError.js\";\n\n/**\n *A receiver that handles sessions, including renewing the session lock.\n */\nexport interface ServiceBusSessionReceiver extends ServiceBusReceiver {\n /**\n * The session ID.\n */\n readonly sessionId: string;\n\n /**\n * The time in UTC until which the session is locked.\n * Every time `renewSessionLock()` is called, this time gets updated to current time plus the lock\n * duration as specified during the Queue/Subscription creation.\n *\n * Will return undefined until a AMQP receiver link has been successfully set up for the session.\n *\n * @readonly\n */\n readonly sessionLockedUntilUtc: Date;\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 * Renews the lock on the session.\n */\n renewSessionLock(options?: OperationOptionsBase): Promise<Date>;\n\n /**\n * Gets the state of the Session. For more on session states, see\n * {@link https://learn.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns The state of that session\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while retrieving session state.\n */\n getSessionState(options?: OperationOptionsBase): Promise<any>;\n\n /**\n * Sets the state on the Session. For more on session states, see\n * {@link https://learn.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}\n * @param state - The state that needs to be set.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while setting the session state.\n *\n */\n setSessionState(state: any, options?: OperationOptionsBase): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusSessionReceiverImpl implements ServiceBusSessionReceiver {\n public sessionId: string;\n public identifier: string;\n\n /**\n * Denotes if close() was called on this receiver\n */\n private _isClosed: boolean = false;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|session:${this.entityPath}]`;\n }\n\n /**\n * @internal\n * @throws Error if the underlying connection is closed.\n * @throws Error if an open receiver is already existing for given sessionId.\n */\n constructor(\n private _messageSession: MessageSession,\n private _context: ConnectionContext,\n public entityPath: string,\n public receiveMode: \"peekLock\" | \"receiveAndDelete\",\n private _skipParsingBodyAsJson: boolean,\n private _skipConvertingDate: boolean,\n private _retryOptions: RetryOptions = {},\n ) {\n throwErrorIfConnectionClosed(_context);\n this.sessionId = _messageSession.sessionId;\n this.identifier = _messageSession.identifier;\n }\n\n private _throwIfReceiverOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n if (this._isClosed) {\n const errorMessage = getReceiverClosedErrorMsg(this.entityPath, this.sessionId);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} already closed`);\n throw error;\n }\n const amqpError: AmqpError = {\n condition: ErrorNameConditionMapper.SessionLockLostError,\n description: `The session lock has expired on the session with id ${this.sessionId}`,\n };\n throw translateServiceBusError(amqpError);\n }\n }\n\n private _throwIfAlreadyReceiving(): void {\n if (this._isReceivingMessages()) {\n const errorMessage = getAlreadyReceivingErrorMsg(this.entityPath, this.sessionId);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is already receiving.`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return (\n this._isClosed ||\n !this._context.messageSessions[this._messageSession.name] ||\n !this._messageSession.isOpen()\n );\n }\n\n /**\n * The time in UTC until which the session is locked.\n * Every time `renewSessionLock()` is called, this time gets updated to current time plus the lock\n * duration as specified during the Queue/Subscription creation.\n *\n * When the lock on the session expires\n * - The current receiver can no longer be used to receive more messages.\n * Create a new receiver using `ServiceBusClient.acceptSession()` or `ServiceBusClient.acceptNextSession()`.\n * - Messages that were received in `peekLock` mode with this receiver but not yet settled\n * will land back in the Queue/Subscription with their delivery count incremented.\n *\n * @readonly\n */\n public get sessionLockedUntilUtc(): Date {\n return this._messageSession.sessionLockedUntilUtc;\n }\n\n /**\n * Renews the lock on the session for the duration as specified during the Queue/Subscription\n * creation. You can check the `sessionLockedUntilUtc` property for the time when the lock expires.\n *\n * When the lock on the session expires\n * - The current receiver can no longer be used to receive mode messages.\n * Create a new receiver using `ServiceBusClient.acceptSession()` or `ServiceBusClient.acceptNextSession()`.\n * - Messages that were received in `peekLock` mode with this receiver but not yet settled\n * will land back in the Queue/Subscription with their delivery count incremented.\n *\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns New lock token expiry date and time in UTC format.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while renewing session lock.\n */\n async renewSessionLock(options?: OperationOptionsBase): Promise<Date> {\n this._throwIfReceiverOrConnectionClosed();\n\n return tracingClient.withSpan(\n \"ServiceBusSessionReceiver.renewSessionLock\",\n options ?? {},\n (updatedOptions) => {\n const renewSessionLockOperationPromise = async (): Promise<Date> => {\n this._messageSession!.sessionLockedUntilUtc = await this._context\n .getManagementClient(this.entityPath)\n .renewSessionLock(this.sessionId, {\n ...updatedOptions,\n associatedLinkName: this._messageSession.name,\n requestName: \"renewSessionLock\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n return this._messageSession!.sessionLockedUntilUtc!;\n };\n const config: RetryConfig<Date> = {\n operation: renewSessionLockOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<Date>(config);\n },\n );\n }\n\n /**\n * Sets the state on the Session. For more on session states, see\n * {@link https://learn.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}\n * @param state - The state that needs to be set.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while setting the session state.\n */\n async setSessionState(state: unknown, options: OperationOptionsBase = {}): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n\n return tracingClient.withSpan(\n \"ServiceBusSessionReceiver.setSessionState\",\n options ?? {},\n (updatedOptions) => {\n const setSessionStateOperationPromise = async (): Promise<void> => {\n await this._context\n .getManagementClient(this.entityPath)\n .setSessionState(this.sessionId!, state, {\n ...updatedOptions,\n associatedLinkName: this._messageSession.name,\n requestName: \"setState\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n return;\n };\n const config: RetryConfig<void> = {\n operation: setSessionStateOperationPromise,\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 }\n\n /**\n * Gets the state of the Session. For more on session states, see\n * {@link https://learn.microsoft.com/azure/service-bus-messaging/message-sessions#message-session-state | Session State}\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns The state of that session\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while retrieving session state.\n */\n async getSessionState(options: OperationOptionsBase = {}): Promise<any> {\n this._throwIfReceiverOrConnectionClosed();\n\n return tracingClient.withSpan(\n \"ServiceBusSessionReceiver.getSessionState\",\n options ?? {},\n (updatedOptions) => {\n const getSessionStateOperationPromise = async (): Promise<any> => {\n return this._context\n .getManagementClient(this.entityPath)\n .getSessionState(this.sessionId, {\n ...updatedOptions,\n associatedLinkName: this._messageSession.name,\n requestName: \"getState\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<any> = {\n operation: getSessionStateOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<any>(config);\n },\n );\n }\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._messageSession.name,\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 this.sessionId,\n omitMessageBody,\n managementRequestOptions,\n );\n } else {\n return this._context\n .getManagementClient(this.entityPath)\n .peekMessagesBySession(\n this.sessionId,\n maxMessageCount,\n omitMessageBody,\n managementRequestOptions,\n );\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 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, this.sessionId, {\n ...options,\n associatedLinkName: this._messageSession.name,\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, this.sessionId, {\n ...options,\n associatedLinkName: this._messageSession.name,\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 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 deletedCount += batchCount;\n }\n }\n return deletedCount;\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 receiveBatchOperationPromise = async (): Promise<ServiceBusReceivedMessage[]> => {\n const receivedMessages = await this._messageSession!.receiveMessages(\n maxMessageCount,\n options?.maxWaitTimeInMs ?? Constants.defaultOperationTimeoutInMs,\n defaultMaxTimeAfterFirstMessageForBatchingMs,\n options ?? {},\n );\n\n return receivedMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: receiveBatchOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.receiveMessage,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config).catch((err) => {\n throw translateServiceBusError(err);\n });\n }\n\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n close(): Promise<void>;\n } {\n // TODO - receiverOptions for subscribe??\n assertValidMessageHandlers(handlers);\n\n options = options ?? {};\n\n const processError = wrapProcessErrorHandler(handlers);\n\n this._registerMessageHandler(\n async (message: ServiceBusMessageImpl) => {\n return tracingClient.withSpan(\n \"SessionReceiver.process\",\n options ?? {},\n () => handlers.processMessage(message),\n toProcessingSpanOptions(message, this, this._context.config, \"process\"),\n );\n },\n processError,\n options,\n );\n\n return {\n close: async (): Promise<void> => {\n return this._messageSession?.receiverHelper.suspend();\n },\n };\n }\n\n /**\n * Registers handlers to deal with the incoming stream of messages over an AMQP receiver link\n * from a Queue/Subscription.\n * To stop receiving messages, call `close()` on the SessionReceiver.\n *\n * Throws an error if there is another receive operation in progress on the same receiver. If you\n * are not sure whether there is another receive operation running, check the `isReceivingMessages`\n * property on the receiver.\n *\n * @param onMessage - Handler for processing each incoming message.\n * @param onError - Handler for any error that occurs while receiving or processing messages.\n * @param options - Options to control whether messages should be automatically completed\n * or if the lock on the session should be automatically renewed. You can control the\n * maximum number of messages that should be concurrently processed. You can\n * also provide a timeout in milliseconds to denote the amount of time to wait for a new message\n * before closing the receiver.\n *\n * @throws Error if the underlying connection or receiver is closed.\n * @throws Error if the receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages. These are bubbled up to be handled by user provided `onError` handler.\n */\n private _registerMessageHandler(\n onMessage: OnMessage,\n onError: OnError,\n options: SubscribeOptions,\n ): void {\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n const connId = this._context.connectionId;\n throwTypeErrorIfParameterMissing(connId, \"onMessage\", onMessage);\n throwTypeErrorIfParameterMissing(connId, \"onError\", onError);\n if (typeof onMessage !== \"function\") {\n throw new TypeError(\"The parameter 'onMessage' must be of type 'function'.\");\n }\n if (typeof onError !== \"function\") {\n throw new TypeError(\"The parameter 'onError' must be of type 'function'.\");\n }\n\n try {\n this._messageSession.subscribe(onMessage, onError, options);\n } catch (err: any) {\n onError({\n error: err,\n errorSource: \"receive\",\n entityPath: this.entityPath,\n fullyQualifiedNamespace: this._context.config.host,\n identifier: this.identifier,\n });\n }\n }\n\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage> {\n return getMessageIterator(this, options);\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(): Promise<Date> {\n throw new Error(\"Renewing message lock is an invalid operation when working with sessions.\");\n }\n\n async close(): Promise<void> {\n try {\n await this._messageSession.close();\n } catch (err: any) {\n logger.logError(\n err,\n \"%s An error occurred while closing the SessionReceiver for session %s\",\n this.logPrefix,\n this.sessionId,\n );\n throw err;\n } finally {\n this._isClosed = true;\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 return this._messageSession ? this._messageSession.isReceivingMessages : false;\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://
|
|
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).__
|
|
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;;;AA4YlC,4DAcC;AAvZD,8DAAwD;AAGxD,gDAQ0B;AAI1B,gDAA6D;AAG7D,qCAAkD;AAClD,yDAAwE;AACxE,8CAAwD;AACxD,6DAAuD;AACvD,iGAAiF;AA2HjF;;GAEG;AACH,MAAa,oBAAoB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G,IAAI,CAAC;YACtB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QAC7B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,qBAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,6CAA6C,CAAC,CAAC;YACrF,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAhPD,oDAgPC;AAED;;GAEG;AACH,SAAgB,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://docs.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;;;AA4YlC,4DAcC;AAvZD,8DAAwD;AAGxD,gDAQ0B;AAI1B,gDAA6D;AAG7D,qCAAkD;AAClD,yDAAwE;AACxE,8CAAwD;AACxD,6DAAuD;AACvD,iGAAiF;AA2HjF;;GAEG;AACH,MAAa,oBAAoB;IAU/B,IAAY,SAAS;QACnB,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,WAAW,IAAI,CAAC,UAAU,GAAG,CAAC;IACrE,CAAC;IAED;;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M,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,6CAA6C,CAAC,CAAC;YACrF,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAhPD,oDAgPC;AAED;;GAEG;AACH,SAAgB,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"]}
|
|
@@ -58,7 +58,7 @@ export declare class ServiceBusClient {
|
|
|
58
58
|
*
|
|
59
59
|
* To target sub queues like the dead letter queue or the transfer dead letter queue, provide the
|
|
60
60
|
* `subQueue` in the options. To learn more about dead letter queues, see
|
|
61
|
-
* https://
|
|
61
|
+
* https://learn.microsoft.com/azure/service-bus-messaging/service-bus-dead-letter-queues
|
|
62
62
|
*
|
|
63
63
|
* You can choose between two receive modes: "peekLock" (default) and "receiveAndDelete".
|
|
64
64
|
* - In peekLock mode, the receiver has a lock on the message for the duration specified on the
|
|
@@ -73,7 +73,7 @@ export declare class ServiceBusClient {
|
|
|
73
73
|
* deadletterMessage() methods on the receiver.
|
|
74
74
|
*
|
|
75
75
|
* More information about how peekLock and message settlement works here:
|
|
76
|
-
* https://
|
|
76
|
+
* https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock
|
|
77
77
|
*
|
|
78
78
|
* @param queueName - The name of the queue to receive from.
|
|
79
79
|
* @param options - Options to pass the receiveMode, defaulted to peekLock.
|
|
@@ -86,7 +86,7 @@ export declare class ServiceBusClient {
|
|
|
86
86
|
*
|
|
87
87
|
* To target sub queues like the dead letter queue or the transfer dead letter queue, provide the
|
|
88
88
|
* `subQueue` in the options. To learn more about dead letter queues, see
|
|
89
|
-
* https://
|
|
89
|
+
* https://learn.microsoft.com/azure/service-bus-messaging/service-bus-dead-letter-queues
|
|
90
90
|
*
|
|
91
91
|
* You can choose between two receive modes: "peekLock" (default) and "receiveAndDelete".
|
|
92
92
|
* - In peekLock mode, the receiver has a lock on the message for the duration specified on the
|
|
@@ -101,7 +101,7 @@ export declare class ServiceBusClient {
|
|
|
101
101
|
* deadletterMessage() methods on the receiver.
|
|
102
102
|
*
|
|
103
103
|
* More information about how peekLock and message settlement works here:
|
|
104
|
-
* https://
|
|
104
|
+
* https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock
|
|
105
105
|
*
|
|
106
106
|
* @param topicName - Name of the topic for the subscription we want to receive from.
|
|
107
107
|
* @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.
|
|
@@ -130,7 +130,7 @@ export declare class ServiceBusClient {
|
|
|
130
130
|
* deadletterMessage() methods on the receiver.
|
|
131
131
|
*
|
|
132
132
|
* More information about how peekLock and message settlement works here:
|
|
133
|
-
* https://
|
|
133
|
+
* https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock
|
|
134
134
|
*
|
|
135
135
|
* @param queueName - The name of the queue to receive from.
|
|
136
136
|
* @param sessionId - The id of the session from which messages need to be received
|
|
@@ -150,7 +150,7 @@ export declare class ServiceBusClient {
|
|
|
150
150
|
* deadletterMessage() methods on the receiver.
|
|
151
151
|
*
|
|
152
152
|
* More information about how peekLock and message settlement works here:
|
|
153
|
-
* https://
|
|
153
|
+
* https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock
|
|
154
154
|
*
|
|
155
155
|
* @param topicName - Name of the topic for the subscription we want to receive from.
|
|
156
156
|
* @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.
|
|
@@ -171,7 +171,7 @@ export declare class ServiceBusClient {
|
|
|
171
171
|
* deadletterMessage() methods on the receiver.
|
|
172
172
|
*
|
|
173
173
|
* More information about how peekLock and message settlement works here:
|
|
174
|
-
* https://
|
|
174
|
+
* https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock
|
|
175
175
|
*
|
|
176
176
|
* @param queueName - The name of the queue to receive from.
|
|
177
177
|
* @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.
|
|
@@ -190,7 +190,7 @@ export declare class ServiceBusClient {
|
|
|
190
190
|
* deadletterMessage() methods on the receiver.
|
|
191
191
|
*
|
|
192
192
|
* More information about how peekLock and message settlement works here:
|
|
193
|
-
* https://
|
|
193
|
+
* https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock
|
|
194
194
|
*
|
|
195
195
|
* @param topicName - Name of the topic for the subscription we want to receive from.
|
|
196
196
|
* @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceBusClient.js","sourceRoot":"","sources":["../../src/serviceBusClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA6flC,4DAoCC;AA5hBD,mEAGiC;AACjC,iEAA2D;AAQ3D,yDAAiE;AAEjE,uEAA+E;AAE/E,yEAAuE;AAEvE,2CAAmD;AACnD,gDAA2D;AAC3D,mEAA6D;AAC7D,gDAA6C;AAC7C,wDAAoD;AACpD,8CAAwD;AAExD;;;GAGG;AACH,MAAa,gBAAgB;IA+C3B,YACE,0CAAkD,EAClD,oBAI2B,EAC3B,QAAkC;QAElC,IAAI,IAAA,4BAAY,EAAC,oBAAoB,CAAC,EAA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I,KAAK,CAAC,mCAAuB,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectionConfig } from \"@azure/core-amqp\";\nimport type { TokenCredential, NamedKeyCredential, SASCredential } from \"@azure/core-auth\";\nimport type { ServiceBusClientOptions } from \"./constructorHelpers.js\";\nimport {\n createConnectionContextForConnectionString,\n createConnectionContextForCredential,\n} from \"./constructorHelpers.js\";\nimport { ConnectionContext } from \"./connectionContext.js\";\nimport type {\n ServiceBusReceiverOptions,\n ServiceBusSessionReceiverOptions,\n ReceiveMode,\n ServiceBusSenderOptions,\n} from \"./models.js\";\nimport type { ServiceBusReceiver } from \"./receivers/receiver.js\";\nimport { ServiceBusReceiverImpl } from \"./receivers/receiver.js\";\nimport type { ServiceBusSessionReceiver } from \"./receivers/sessionReceiver.js\";\nimport { ServiceBusSessionReceiverImpl } from \"./receivers/sessionReceiver.js\";\nimport type { ServiceBusRuleManager } from \"./serviceBusRuleManager.js\";\nimport { ServiceBusRuleManagerImpl } from \"./serviceBusRuleManager.js\";\nimport type { ServiceBusSender } from \"./sender.js\";\nimport { ServiceBusSenderImpl } from \"./sender.js\";\nimport { entityPathMisMatchError } from \"./util/errors.js\";\nimport { MessageSession } from \"./session/messageSession.js\";\nimport { isDefined } from \"@azure/core-util\";\nimport { isCredential } from \"./util/typeGuards.js\";\nimport { ensureValidIdentifier } from \"./util/utils.js\";\n\n/**\n * A client that can create Sender instances for sending messages to queues and\n * topics as well as Receiver instances to receive messages from queues and subscriptions.\n */\nexport class ServiceBusClient {\n private _connectionContext: ConnectionContext;\n private _clientOptions: ServiceBusClientOptions;\n /**\n * The fully qualified namespace of the Service Bus instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n public fullyQualifiedNamespace: string;\n /**\n * The name used to identify this ServiceBusClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public identifier: string;\n /**\n * Creates an instance of the ServiceBusClient class which can be used to create senders and receivers to\n * the Azure Service Bus namespace provided in the connection string. No connection is made to the service\n * until the senders/receivers created with the client are used to send/receive messages.\n * @param connectionString - A connection string for Azure Service Bus namespace.\n * NOTE: this connection string can contain an EntityPath, which is ignored.\n * @param options - Options for the service bus client.\n */\n constructor(connectionString: string, options?: ServiceBusClientOptions);\n /**\n * Creates an instance of the ServiceBusClient class which can be used to create senders and receivers to\n * the Azure Service Bus namespace provided. No connection is made to the service until\n * the senders/receivers created with the client are used to send/receive messages.\n * @param fullyQualifiedNamespace - The full namespace of your Service Bus instance which is\n * likely to be similar to <yournamespace>.servicebus.windows.net.\n * @param credential - A credential object used by the client to get the token to authenticate the connection\n * with the Azure Service Bus. See @azure/identity for creating the credentials.\n * If you're using an own implementation of the `TokenCredential` interface against AAD, then set the \"scopes\" for service-bus\n * to be `[\"https://servicebus.azure.net//user_impersonation\"]` to get the appropriate token.\n * Use the `AzureNamedKeyCredential` from @azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from @azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n */\n constructor(\n fullyQualifiedNamespace: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options?: ServiceBusClientOptions,\n );\n constructor(\n fullyQualifiedNamespaceOrConnectionString1: string,\n credentialOrOptions2?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | ServiceBusClientOptions,\n options3?: ServiceBusClientOptions,\n ) {\n if (isCredential(credentialOrOptions2)) {\n const fullyQualifiedNamespace: string = fullyQualifiedNamespaceOrConnectionString1;\n const credential = credentialOrOptions2;\n this._clientOptions = options3 || {};\n\n this._connectionContext = createConnectionContextForCredential(\n credential,\n fullyQualifiedNamespace,\n this._clientOptions,\n );\n } else {\n const connectionString: string = fullyQualifiedNamespaceOrConnectionString1;\n this._clientOptions = credentialOrOptions2 || {};\n\n this._connectionContext = createConnectionContextForConnectionString(\n connectionString,\n this._clientOptions,\n );\n }\n this.fullyQualifiedNamespace = this._connectionContext.config.host;\n this.identifier = ensureValidIdentifier(\n this.fullyQualifiedNamespace,\n this._clientOptions.identifier,\n );\n this._clientOptions.retryOptions = this._clientOptions.retryOptions || {};\n\n const timeoutInMs = this._clientOptions.retryOptions.timeoutInMs;\n if (\n isDefined(timeoutInMs) &&\n (typeof timeoutInMs !== \"number\" || !isFinite(timeoutInMs) || timeoutInMs <= 0)\n ) {\n throw new Error(`${timeoutInMs} is an invalid value for retryOptions.timeoutInMs`);\n }\n }\n\n /**\n * Creates a receiver for an Azure Service Bus queue. No connection is made\n * to the service until one of the methods on the receiver is called.\n *\n * To target sub queues like the dead letter queue or the transfer dead letter queue, provide the\n * `subQueue` in the options. To learn more about dead letter queues, see\n * https://docs.microsoft.com/azure/service-bus-messaging/service-bus-dead-letter-queues\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * Messages that are not settled within the lock duration will be redelivered as many times as\n * the max delivery count set on the queue, after which they get sent to a separate dead letter\n * queue.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://docs.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param queueName - The name of the queue to receive from.\n * @param options - Options to pass the receiveMode, defaulted to peekLock.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n createReceiver(queueName: string, options?: ServiceBusReceiverOptions): ServiceBusReceiver;\n /**\n * Creates a receiver for an Azure Service Bus subscription. No connection is made\n * to the service until one of the methods on the receiver is called.\n *\n * To target sub queues like the dead letter queue or the transfer dead letter queue, provide the\n * `subQueue` in the options. To learn more about dead letter queues, see\n * https://docs.microsoft.com/azure/service-bus-messaging/service-bus-dead-letter-queues\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * Messages that are not settled within the lock duration will be redelivered as many times as\n * the max delivery count set on the subscription, after which they get sent to a separate dead letter\n * queue.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://docs.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param topicName - Name of the topic for the subscription we want to receive from.\n * @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.\n * @param options - Options to pass the receiveMode, defaulted to peekLock.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n createReceiver(\n topicName: string,\n subscriptionName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusReceiverOptions,\n ): ServiceBusReceiver;\n createReceiver(\n queueOrTopicName1: string,\n optionsOrSubscriptionName2?: ServiceBusReceiverOptions | string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options3?: ServiceBusReceiverOptions,\n ): ServiceBusReceiver {\n validateEntityPath(this._connectionContext.config, queueOrTopicName1);\n\n // NOTE: we don't currently have any options for this kind of receiver but\n // when we do make sure you pass them in and extract them.\n const { entityPath, receiveMode, options } = extractReceiverArguments(\n queueOrTopicName1,\n optionsOrSubscriptionName2,\n options3,\n );\n\n let entityPathWithSubQueue = entityPath;\n if (options?.subQueueType) {\n switch (options?.subQueueType) {\n case \"deadLetter\":\n entityPathWithSubQueue += \"/$DeadLetterQueue\";\n break;\n case \"transferDeadLetter\":\n entityPathWithSubQueue += \"/$Transfer/$DeadLetterQueue\";\n break;\n default:\n throw new Error(\n `Invalid subQueueType '${options?.subQueueType}' provided. Valid values are 'deadLetter' and 'transferDeadLetter'`,\n );\n }\n }\n\n const maxLockAutoRenewDurationInMs =\n options?.maxAutoLockRenewalDurationInMs != null\n ? options.maxAutoLockRenewalDurationInMs\n : 5 * 60 * 1000;\n\n return new ServiceBusReceiverImpl(\n this._connectionContext,\n entityPathWithSubQueue,\n receiveMode,\n maxLockAutoRenewDurationInMs,\n options?.skipParsingBodyAsJson ?? false,\n options?.skipConvertingDate ?? false,\n this._clientOptions.retryOptions,\n options?.identifier,\n );\n }\n\n /**\n * Creates an instance of {@link ServiceBusRuleManager} that is used to manage\n * the rules for a subscription.\n *\n * @param topicName - the topic to create {@link ServiceBusRuleManager}\n * @param subscriptionName - the subscription specific to the specified topic to create a {@link ServiceBusRuleManager} for.\n * @returns a {@link ServiceBusRuleManager} scoped to the specified subscription and topic.\n */\n createRuleManager(topicName: string, subscriptionName: string): ServiceBusRuleManager {\n validateEntityPath(this._connectionContext.config, topicName);\n\n const { entityPath } = extractReceiverArguments(topicName, subscriptionName);\n return new ServiceBusRuleManagerImpl(\n this._connectionContext,\n entityPath,\n this._clientOptions.retryOptions,\n );\n }\n\n /**\n * Creates a receiver for a session enabled Azure Service Bus queue.\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://docs.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param queueName - The name of the queue to receive from.\n * @param sessionId - The id of the session from which messages need to be received\n * @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n acceptSession(\n queueName: string,\n sessionId: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver>;\n /**\n * Creates a receiver for a session enabled Azure Service Bus subscription.\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://docs.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param topicName - Name of the topic for the subscription we want to receive from.\n * @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.\n * @param sessionId - The id of the session from which messages need to be received\n * @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n acceptSession(\n topicName: string,\n subscriptionName: string,\n sessionId: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver>;\n async acceptSession(\n queueOrTopicName1: string,\n optionsOrSubscriptionNameOrSessionId2?: ServiceBusSessionReceiverOptions | string,\n optionsOrSessionId3?: ServiceBusSessionReceiverOptions | string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options4?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver> {\n validateEntityPath(this._connectionContext.config, queueOrTopicName1);\n\n let sessionId: string;\n let entityPath: string;\n let receiveMode: \"peekLock\" | \"receiveAndDelete\";\n let options: ServiceBusSessionReceiverOptions | undefined;\n\n if (\n typeof queueOrTopicName1 === \"string\" &&\n typeof optionsOrSubscriptionNameOrSessionId2 === \"string\" &&\n typeof optionsOrSessionId3 === \"string\"\n ) {\n // subscription constructor\n sessionId = optionsOrSessionId3;\n\n ({ entityPath, receiveMode, options } = extractReceiverArguments(\n queueOrTopicName1,\n optionsOrSubscriptionNameOrSessionId2,\n // skip the session ID parameter (3)\n options4,\n ));\n } else if (\n typeof queueOrTopicName1 === \"string\" &&\n typeof optionsOrSubscriptionNameOrSessionId2 === \"string\" &&\n typeof optionsOrSessionId3 !== \"string\"\n ) {\n // queue constructor (but only because we know we're not a subscription constructor)\n sessionId = optionsOrSubscriptionNameOrSessionId2;\n\n ({ entityPath, receiveMode, options } = extractReceiverArguments(\n queueOrTopicName1,\n // skip the session ID parameter (2)\n optionsOrSessionId3,\n undefined,\n ));\n } else {\n throw new Error(\"Unhandled set of parameters\");\n }\n\n const messageSession = await MessageSession.create(\n ensureValidIdentifier(entityPath, options?.identifier),\n this._connectionContext,\n entityPath,\n sessionId,\n {\n maxAutoLockRenewalDurationInMs: options?.maxAutoLockRenewalDurationInMs,\n receiveMode,\n abortSignal: options?.abortSignal,\n retryOptions: this._clientOptions.retryOptions,\n skipParsingBodyAsJson: options?.skipParsingBodyAsJson ?? false,\n skipConvertingDate: options?.skipConvertingDate ?? false,\n },\n );\n\n const sessionReceiver = new ServiceBusSessionReceiverImpl(\n messageSession,\n this._connectionContext,\n entityPath,\n receiveMode,\n options?.skipParsingBodyAsJson ?? false,\n options?.skipConvertingDate ?? false,\n this._clientOptions.retryOptions,\n );\n\n return sessionReceiver;\n }\n\n /**\n * Creates a receiver for the next available session in a session-enabled Azure Service Bus queue.\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://docs.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param queueName - The name of the queue to receive from.\n * @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n acceptNextSession(\n queueName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver>;\n /**\n * Creates a receiver for the next available session in a session-enabled Azure Service Bus subscription.\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://docs.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param topicName - Name of the topic for the subscription we want to receive from.\n * @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.\n * @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n acceptNextSession(\n topicName: string,\n subscriptionName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver>;\n async acceptNextSession(\n queueOrTopicName1: string,\n optionsOrSubscriptionName2?: ServiceBusSessionReceiverOptions | string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options3?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver> {\n validateEntityPath(this._connectionContext.config, queueOrTopicName1);\n\n const { entityPath, receiveMode, options } = extractReceiverArguments(\n queueOrTopicName1,\n optionsOrSubscriptionName2,\n options3,\n );\n\n const messageSession = await MessageSession.create(\n ensureValidIdentifier(entityPath, options?.identifier),\n this._connectionContext,\n entityPath,\n undefined,\n {\n maxAutoLockRenewalDurationInMs: options?.maxAutoLockRenewalDurationInMs,\n receiveMode,\n abortSignal: options?.abortSignal,\n retryOptions: this._clientOptions.retryOptions,\n skipParsingBodyAsJson: options?.skipParsingBodyAsJson ?? false,\n skipConvertingDate: options?.skipConvertingDate ?? false,\n },\n );\n\n const sessionReceiver = new ServiceBusSessionReceiverImpl(\n messageSession,\n this._connectionContext,\n entityPath,\n receiveMode,\n options?.skipParsingBodyAsJson ?? false,\n options?.skipConvertingDate ?? false,\n this._clientOptions.retryOptions,\n );\n\n return sessionReceiver;\n }\n\n /**\n * Creates a Sender which can be used to send messages, schedule messages to be\n * sent at a later time and cancel such scheduled messages. No connection is made\n * to the service until one of the methods on the sender is called.\n * @param queueOrTopicName - The name of a queue or topic to send messages to.\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n createSender(queueOrTopicName: string, options: ServiceBusSenderOptions = {}): ServiceBusSender {\n validateEntityPath(this._connectionContext.config, queueOrTopicName);\n\n return new ServiceBusSenderImpl(\n this._connectionContext,\n queueOrTopicName,\n this._clientOptions.retryOptions,\n options.identifier,\n );\n }\n\n /**\n * Closes the underlying AMQP connection.\n * NOTE: this will also disconnect any Receiver or Sender instances created from this\n * instance.\n */\n close(): Promise<void> {\n return ConnectionContext.close(this._connectionContext);\n }\n}\n\n/**\n * Helper to validate and extract the common arguments from both the create*Receiver() overloads that\n * have this pattern:\n *\n * queue, options\n * topic, subscription, options\n *\n * @internal\n */\nexport function extractReceiverArguments<OptionsT extends { receiveMode?: ReceiveMode }>(\n queueOrTopicName1: string,\n optionsOrSubscriptionName2: string | OptionsT | undefined,\n definitelyOptions3?: OptionsT,\n): {\n entityPath: string;\n receiveMode: ReceiveMode;\n options?: Omit<OptionsT, \"receiveMode\">;\n} {\n let entityPath: string;\n let options: OptionsT | undefined;\n if (typeof optionsOrSubscriptionName2 === \"string\") {\n const topic = queueOrTopicName1;\n const subscription = optionsOrSubscriptionName2;\n entityPath = `${topic}/Subscriptions/${subscription}`;\n options = definitelyOptions3;\n } else {\n entityPath = queueOrTopicName1;\n options = optionsOrSubscriptionName2;\n }\n let receiveMode: ReceiveMode;\n if (!options || !isDefined(options.receiveMode) || options.receiveMode === \"peekLock\") {\n receiveMode = \"peekLock\";\n } else if (options.receiveMode === \"receiveAndDelete\") {\n receiveMode = \"receiveAndDelete\";\n } else {\n throw new TypeError(\n `Invalid receiveMode '${options?.receiveMode}' provided. Valid values are 'peekLock' and 'receiveAndDelete'`,\n );\n }\n delete options?.receiveMode;\n return {\n entityPath,\n receiveMode,\n options,\n };\n}\n\n/**\n * Validates that the EntityPath in the connection string (if any) matches with the\n * queue or topic name passed to the methods that create senders and receivers.\n *\n * @internal\n */\nfunction validateEntityPath(connectionConfig: ConnectionConfig, queueOrTopicName: string): void {\n if (connectionConfig.entityPath && connectionConfig.entityPath !== queueOrTopicName) {\n throw new Error(entityPathMisMatchError);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serviceBusClient.js","sourceRoot":"","sources":["../../src/serviceBusClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA6flC,4DAoCC;AA5hBD,mEAGiC;AACjC,iEAA2D;AAQ3D,yDAAiE;AAEjE,uEAA+E;AAE/E,yEAAuE;AAEvE,2CAAmD;AACnD,gDAA2D;AAC3D,mEAA6D;AAC7D,gDAA6C;AAC7C,wDAAoD;AACpD,8CAAwD;AAExD;;;GAGG;AACH,MAAa,gBAAgB;IA+C3B,YACE,0CAAkD,EAClD,oBAI2B,EAC3B,QAAkC;QAElC,IAAI,IAAA,4BAAY,EAAC,oBAAoB,CAAC,EAAE,CAAC;YACvC,MAAM,uBAAuB,GAAW,0CAA0C,CAAC;YACnF,MAAM,UAAU,GAAG,oBAAoB,CAAC;YACxC,IAAI,CAAC,cAAc,GAAG,QAAQ,IAAI,EAAE,CAAC;YAErC,IAAI,CAAC,kBAAkB,GAAG,IAAA,4DAAoC,EAC5D,U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C;IAClC,IAAI,OAAO,0BAA0B,KAAK,QAAQ,EAAE,CAAC;QACnD,MAAM,KAAK,GAAG,iBAAiB,CAAC;QAChC,MAAM,YAAY,GAAG,0BAA0B,CAAC;QAChD,UAAU,GAAG,GAAG,KAAK,kBAAkB,YAAY,EAAE,CAAC;QACtD,OAAO,GAAG,kBAAkB,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,iBAAiB,CAAC;QAC/B,OAAO,GAAG,0BAA0B,CAAC;IACvC,CAAC;IACD,IAAI,WAAwB,CAAC;IAC7B,IAAI,CAAC,OAAO,IAAI,CAAC,IAAA,qBAAS,EAAC,OAAO,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,WAAW,KAAK,UAAU,EAAE,CAAC;QACtF,WAAW,GAAG,UAAU,CAAC;IAC3B,CAAC;SAAM,IAAI,OAAO,CAAC,WAAW,KAAK,kBAAkB,EAAE,CAAC;QACtD,WAAW,GAAG,kBAAkB,CAAC;IACnC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,SAAS,CACjB,wBAAwB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,gEAAgE,CAC7G,CAAC;IACJ,CAAC;IACM,OAAO,aAAP,OAAO,4BAAP,OAAO,CAAE,WAAW,CAAC;IAC5B,OAAO;QACL,UAAU;QACV,WAAW;QACX,OAAO;KACR,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,gBAAkC,EAAE,gBAAwB;IACtF,IAAI,gBAAgB,CAAC,UAAU,IAAI,gBAAgB,CAAC,UAAU,KAAK,gBAAgB,EAAE,CAAC;QACpF,MAAM,IAAI,KAAK,CAAC,mCAAuB,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConnectionConfig } from \"@azure/core-amqp\";\nimport type { TokenCredential, NamedKeyCredential, SASCredential } from \"@azure/core-auth\";\nimport type { ServiceBusClientOptions } from \"./constructorHelpers.js\";\nimport {\n createConnectionContextForConnectionString,\n createConnectionContextForCredential,\n} from \"./constructorHelpers.js\";\nimport { ConnectionContext } from \"./connectionContext.js\";\nimport type {\n ServiceBusReceiverOptions,\n ServiceBusSessionReceiverOptions,\n ReceiveMode,\n ServiceBusSenderOptions,\n} from \"./models.js\";\nimport type { ServiceBusReceiver } from \"./receivers/receiver.js\";\nimport { ServiceBusReceiverImpl } from \"./receivers/receiver.js\";\nimport type { ServiceBusSessionReceiver } from \"./receivers/sessionReceiver.js\";\nimport { ServiceBusSessionReceiverImpl } from \"./receivers/sessionReceiver.js\";\nimport type { ServiceBusRuleManager } from \"./serviceBusRuleManager.js\";\nimport { ServiceBusRuleManagerImpl } from \"./serviceBusRuleManager.js\";\nimport type { ServiceBusSender } from \"./sender.js\";\nimport { ServiceBusSenderImpl } from \"./sender.js\";\nimport { entityPathMisMatchError } from \"./util/errors.js\";\nimport { MessageSession } from \"./session/messageSession.js\";\nimport { isDefined } from \"@azure/core-util\";\nimport { isCredential } from \"./util/typeGuards.js\";\nimport { ensureValidIdentifier } from \"./util/utils.js\";\n\n/**\n * A client that can create Sender instances for sending messages to queues and\n * topics as well as Receiver instances to receive messages from queues and subscriptions.\n */\nexport class ServiceBusClient {\n private _connectionContext: ConnectionContext;\n private _clientOptions: ServiceBusClientOptions;\n /**\n * The fully qualified namespace of the Service Bus instance for which this client is created.\n * This is likely to be similar to <yournamespace>.servicebus.windows.net.\n */\n public fullyQualifiedNamespace: string;\n /**\n * The name used to identify this ServiceBusClient.\n * If not specified or empty, a random unique one will be generated.\n */\n public identifier: string;\n /**\n * Creates an instance of the ServiceBusClient class which can be used to create senders and receivers to\n * the Azure Service Bus namespace provided in the connection string. No connection is made to the service\n * until the senders/receivers created with the client are used to send/receive messages.\n * @param connectionString - A connection string for Azure Service Bus namespace.\n * NOTE: this connection string can contain an EntityPath, which is ignored.\n * @param options - Options for the service bus client.\n */\n constructor(connectionString: string, options?: ServiceBusClientOptions);\n /**\n * Creates an instance of the ServiceBusClient class which can be used to create senders and receivers to\n * the Azure Service Bus namespace provided. No connection is made to the service until\n * the senders/receivers created with the client are used to send/receive messages.\n * @param fullyQualifiedNamespace - The full namespace of your Service Bus instance which is\n * likely to be similar to <yournamespace>.servicebus.windows.net.\n * @param credential - A credential object used by the client to get the token to authenticate the connection\n * with the Azure Service Bus. See @azure/identity for creating the credentials.\n * If you're using an own implementation of the `TokenCredential` interface against AAD, then set the \"scopes\" for service-bus\n * to be `[\"https://servicebus.azure.net//user_impersonation\"]` to get the appropriate token.\n * Use the `AzureNamedKeyCredential` from @azure/core-auth if you want to pass in a `SharedAccessKeyName`\n * and `SharedAccessKey` without using a connection string. These fields map to the `name` and `key` field respectively\n * in `AzureNamedKeyCredential`.\n * Use the `AzureSASCredential` from @azure/core-auth if you want to pass in a `SharedAccessSignature`\n * without using a connection string. This field maps to `signature` in `AzureSASCredential`.\n * @param options - A set of options to apply when configuring the client.\n * - `retryOptions` : Configures the retry policy for all the operations on the client.\n * For example, `{ \"maxRetries\": 4 }` or `{ \"maxRetries\": 4, \"retryDelayInMs\": 30000 }`.\n * - `webSocketOptions`: Configures the channelling of the AMQP connection over Web Sockets.\n */\n constructor(\n fullyQualifiedNamespace: string,\n credential: TokenCredential | NamedKeyCredential | SASCredential,\n options?: ServiceBusClientOptions,\n );\n constructor(\n fullyQualifiedNamespaceOrConnectionString1: string,\n credentialOrOptions2?:\n | TokenCredential\n | NamedKeyCredential\n | SASCredential\n | ServiceBusClientOptions,\n options3?: ServiceBusClientOptions,\n ) {\n if (isCredential(credentialOrOptions2)) {\n const fullyQualifiedNamespace: string = fullyQualifiedNamespaceOrConnectionString1;\n const credential = credentialOrOptions2;\n this._clientOptions = options3 || {};\n\n this._connectionContext = createConnectionContextForCredential(\n credential,\n fullyQualifiedNamespace,\n this._clientOptions,\n );\n } else {\n const connectionString: string = fullyQualifiedNamespaceOrConnectionString1;\n this._clientOptions = credentialOrOptions2 || {};\n\n this._connectionContext = createConnectionContextForConnectionString(\n connectionString,\n this._clientOptions,\n );\n }\n this.fullyQualifiedNamespace = this._connectionContext.config.host;\n this.identifier = ensureValidIdentifier(\n this.fullyQualifiedNamespace,\n this._clientOptions.identifier,\n );\n this._clientOptions.retryOptions = this._clientOptions.retryOptions || {};\n\n const timeoutInMs = this._clientOptions.retryOptions.timeoutInMs;\n if (\n isDefined(timeoutInMs) &&\n (typeof timeoutInMs !== \"number\" || !isFinite(timeoutInMs) || timeoutInMs <= 0)\n ) {\n throw new Error(`${timeoutInMs} is an invalid value for retryOptions.timeoutInMs`);\n }\n }\n\n /**\n * Creates a receiver for an Azure Service Bus queue. No connection is made\n * to the service until one of the methods on the receiver is called.\n *\n * To target sub queues like the dead letter queue or the transfer dead letter queue, provide the\n * `subQueue` in the options. To learn more about dead letter queues, see\n * https://learn.microsoft.com/azure/service-bus-messaging/service-bus-dead-letter-queues\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * Messages that are not settled within the lock duration will be redelivered as many times as\n * the max delivery count set on the queue, after which they get sent to a separate dead letter\n * queue.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param queueName - The name of the queue to receive from.\n * @param options - Options to pass the receiveMode, defaulted to peekLock.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n createReceiver(queueName: string, options?: ServiceBusReceiverOptions): ServiceBusReceiver;\n /**\n * Creates a receiver for an Azure Service Bus subscription. No connection is made\n * to the service until one of the methods on the receiver is called.\n *\n * To target sub queues like the dead letter queue or the transfer dead letter queue, provide the\n * `subQueue` in the options. To learn more about dead letter queues, see\n * https://learn.microsoft.com/azure/service-bus-messaging/service-bus-dead-letter-queues\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * Messages that are not settled within the lock duration will be redelivered as many times as\n * the max delivery count set on the subscription, after which they get sent to a separate dead letter\n * queue.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param topicName - Name of the topic for the subscription we want to receive from.\n * @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.\n * @param options - Options to pass the receiveMode, defaulted to peekLock.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n createReceiver(\n topicName: string,\n subscriptionName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusReceiverOptions,\n ): ServiceBusReceiver;\n createReceiver(\n queueOrTopicName1: string,\n optionsOrSubscriptionName2?: ServiceBusReceiverOptions | string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options3?: ServiceBusReceiverOptions,\n ): ServiceBusReceiver {\n validateEntityPath(this._connectionContext.config, queueOrTopicName1);\n\n // NOTE: we don't currently have any options for this kind of receiver but\n // when we do make sure you pass them in and extract them.\n const { entityPath, receiveMode, options } = extractReceiverArguments(\n queueOrTopicName1,\n optionsOrSubscriptionName2,\n options3,\n );\n\n let entityPathWithSubQueue = entityPath;\n if (options?.subQueueType) {\n switch (options?.subQueueType) {\n case \"deadLetter\":\n entityPathWithSubQueue += \"/$DeadLetterQueue\";\n break;\n case \"transferDeadLetter\":\n entityPathWithSubQueue += \"/$Transfer/$DeadLetterQueue\";\n break;\n default:\n throw new Error(\n `Invalid subQueueType '${options?.subQueueType}' provided. Valid values are 'deadLetter' and 'transferDeadLetter'`,\n );\n }\n }\n\n const maxLockAutoRenewDurationInMs =\n options?.maxAutoLockRenewalDurationInMs != null\n ? options.maxAutoLockRenewalDurationInMs\n : 5 * 60 * 1000;\n\n return new ServiceBusReceiverImpl(\n this._connectionContext,\n entityPathWithSubQueue,\n receiveMode,\n maxLockAutoRenewDurationInMs,\n options?.skipParsingBodyAsJson ?? false,\n options?.skipConvertingDate ?? false,\n this._clientOptions.retryOptions,\n options?.identifier,\n );\n }\n\n /**\n * Creates an instance of {@link ServiceBusRuleManager} that is used to manage\n * the rules for a subscription.\n *\n * @param topicName - the topic to create {@link ServiceBusRuleManager}\n * @param subscriptionName - the subscription specific to the specified topic to create a {@link ServiceBusRuleManager} for.\n * @returns a {@link ServiceBusRuleManager} scoped to the specified subscription and topic.\n */\n createRuleManager(topicName: string, subscriptionName: string): ServiceBusRuleManager {\n validateEntityPath(this._connectionContext.config, topicName);\n\n const { entityPath } = extractReceiverArguments(topicName, subscriptionName);\n return new ServiceBusRuleManagerImpl(\n this._connectionContext,\n entityPath,\n this._clientOptions.retryOptions,\n );\n }\n\n /**\n * Creates a receiver for a session enabled Azure Service Bus queue.\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param queueName - The name of the queue to receive from.\n * @param sessionId - The id of the session from which messages need to be received\n * @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n acceptSession(\n queueName: string,\n sessionId: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver>;\n /**\n * Creates a receiver for a session enabled Azure Service Bus subscription.\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param topicName - Name of the topic for the subscription we want to receive from.\n * @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.\n * @param sessionId - The id of the session from which messages need to be received\n * @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n acceptSession(\n topicName: string,\n subscriptionName: string,\n sessionId: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver>;\n async acceptSession(\n queueOrTopicName1: string,\n optionsOrSubscriptionNameOrSessionId2?: ServiceBusSessionReceiverOptions | string,\n optionsOrSessionId3?: ServiceBusSessionReceiverOptions | string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options4?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver> {\n validateEntityPath(this._connectionContext.config, queueOrTopicName1);\n\n let sessionId: string;\n let entityPath: string;\n let receiveMode: \"peekLock\" | \"receiveAndDelete\";\n let options: ServiceBusSessionReceiverOptions | undefined;\n\n if (\n typeof queueOrTopicName1 === \"string\" &&\n typeof optionsOrSubscriptionNameOrSessionId2 === \"string\" &&\n typeof optionsOrSessionId3 === \"string\"\n ) {\n // subscription constructor\n sessionId = optionsOrSessionId3;\n\n ({ entityPath, receiveMode, options } = extractReceiverArguments(\n queueOrTopicName1,\n optionsOrSubscriptionNameOrSessionId2,\n // skip the session ID parameter (3)\n options4,\n ));\n } else if (\n typeof queueOrTopicName1 === \"string\" &&\n typeof optionsOrSubscriptionNameOrSessionId2 === \"string\" &&\n typeof optionsOrSessionId3 !== \"string\"\n ) {\n // queue constructor (but only because we know we're not a subscription constructor)\n sessionId = optionsOrSubscriptionNameOrSessionId2;\n\n ({ entityPath, receiveMode, options } = extractReceiverArguments(\n queueOrTopicName1,\n // skip the session ID parameter (2)\n optionsOrSessionId3,\n undefined,\n ));\n } else {\n throw new Error(\"Unhandled set of parameters\");\n }\n\n const messageSession = await MessageSession.create(\n ensureValidIdentifier(entityPath, options?.identifier),\n this._connectionContext,\n entityPath,\n sessionId,\n {\n maxAutoLockRenewalDurationInMs: options?.maxAutoLockRenewalDurationInMs,\n receiveMode,\n abortSignal: options?.abortSignal,\n retryOptions: this._clientOptions.retryOptions,\n skipParsingBodyAsJson: options?.skipParsingBodyAsJson ?? false,\n skipConvertingDate: options?.skipConvertingDate ?? false,\n },\n );\n\n const sessionReceiver = new ServiceBusSessionReceiverImpl(\n messageSession,\n this._connectionContext,\n entityPath,\n receiveMode,\n options?.skipParsingBodyAsJson ?? false,\n options?.skipConvertingDate ?? false,\n this._clientOptions.retryOptions,\n );\n\n return sessionReceiver;\n }\n\n /**\n * Creates a receiver for the next available session in a session-enabled Azure Service Bus queue.\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param queueName - The name of the queue to receive from.\n * @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n acceptNextSession(\n queueName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver>;\n /**\n * Creates a receiver for the next available session in a session-enabled Azure Service Bus subscription.\n *\n * You can choose between two receive modes: \"peekLock\" (default) and \"receiveAndDelete\".\n * - In peekLock mode, the receiver has a lock on the message for the duration specified on the\n * queue.\n * - In receiveAndDelete mode, messages are deleted from Service Bus as they are received.\n *\n * You can settle a message by calling completeMessage(), abandonMessage(), deferMessage() or\n * deadletterMessage() methods on the receiver.\n *\n * More information about how peekLock and message settlement works here:\n * https://learn.microsoft.com/azure/service-bus-messaging/message-transfers-locks-settlement#peeklock\n *\n * @param topicName - Name of the topic for the subscription we want to receive from.\n * @param subscriptionName - Name of the subscription (under the `topic`) that we want to receive from.\n * @param options - Options include receiveMode(defaulted to peekLock), options to create session receiver.\n * @returns A receiver that can be used to receive, peek and settle messages.\n */\n acceptNextSession(\n topicName: string,\n subscriptionName: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver>;\n async acceptNextSession(\n queueOrTopicName1: string,\n optionsOrSubscriptionName2?: ServiceBusSessionReceiverOptions | string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options3?: ServiceBusSessionReceiverOptions,\n ): Promise<ServiceBusSessionReceiver> {\n validateEntityPath(this._connectionContext.config, queueOrTopicName1);\n\n const { entityPath, receiveMode, options } = extractReceiverArguments(\n queueOrTopicName1,\n optionsOrSubscriptionName2,\n options3,\n );\n\n const messageSession = await MessageSession.create(\n ensureValidIdentifier(entityPath, options?.identifier),\n this._connectionContext,\n entityPath,\n undefined,\n {\n maxAutoLockRenewalDurationInMs: options?.maxAutoLockRenewalDurationInMs,\n receiveMode,\n abortSignal: options?.abortSignal,\n retryOptions: this._clientOptions.retryOptions,\n skipParsingBodyAsJson: options?.skipParsingBodyAsJson ?? false,\n skipConvertingDate: options?.skipConvertingDate ?? false,\n },\n );\n\n const sessionReceiver = new ServiceBusSessionReceiverImpl(\n messageSession,\n this._connectionContext,\n entityPath,\n receiveMode,\n options?.skipParsingBodyAsJson ?? false,\n options?.skipConvertingDate ?? false,\n this._clientOptions.retryOptions,\n );\n\n return sessionReceiver;\n }\n\n /**\n * Creates a Sender which can be used to send messages, schedule messages to be\n * sent at a later time and cancel such scheduled messages. No connection is made\n * to the service until one of the methods on the sender is called.\n * @param queueOrTopicName - The name of a queue or topic to send messages to.\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n createSender(queueOrTopicName: string, options: ServiceBusSenderOptions = {}): ServiceBusSender {\n validateEntityPath(this._connectionContext.config, queueOrTopicName);\n\n return new ServiceBusSenderImpl(\n this._connectionContext,\n queueOrTopicName,\n this._clientOptions.retryOptions,\n options.identifier,\n );\n }\n\n /**\n * Closes the underlying AMQP connection.\n * NOTE: this will also disconnect any Receiver or Sender instances created from this\n * instance.\n */\n close(): Promise<void> {\n return ConnectionContext.close(this._connectionContext);\n }\n}\n\n/**\n * Helper to validate and extract the common arguments from both the create*Receiver() overloads that\n * have this pattern:\n *\n * queue, options\n * topic, subscription, options\n *\n * @internal\n */\nexport function extractReceiverArguments<OptionsT extends { receiveMode?: ReceiveMode }>(\n queueOrTopicName1: string,\n optionsOrSubscriptionName2: string | OptionsT | undefined,\n definitelyOptions3?: OptionsT,\n): {\n entityPath: string;\n receiveMode: ReceiveMode;\n options?: Omit<OptionsT, \"receiveMode\">;\n} {\n let entityPath: string;\n let options: OptionsT | undefined;\n if (typeof optionsOrSubscriptionName2 === \"string\") {\n const topic = queueOrTopicName1;\n const subscription = optionsOrSubscriptionName2;\n entityPath = `${topic}/Subscriptions/${subscription}`;\n options = definitelyOptions3;\n } else {\n entityPath = queueOrTopicName1;\n options = optionsOrSubscriptionName2;\n }\n let receiveMode: ReceiveMode;\n if (!options || !isDefined(options.receiveMode) || options.receiveMode === \"peekLock\") {\n receiveMode = \"peekLock\";\n } else if (options.receiveMode === \"receiveAndDelete\") {\n receiveMode = \"receiveAndDelete\";\n } else {\n throw new TypeError(\n `Invalid receiveMode '${options?.receiveMode}' provided. Valid values are 'peekLock' and 'receiveAndDelete'`,\n );\n }\n delete options?.receiveMode;\n return {\n entityPath,\n receiveMode,\n options,\n };\n}\n\n/**\n * Validates that the EntityPath in the connection string (if any) matches with the\n * queue or topic name passed to the methods that create senders and receivers.\n *\n * @internal\n */\nfunction validateEntityPath(connectionConfig: ConnectionConfig, queueOrTopicName: string): void {\n if (connectionConfig.entityPath && connectionConfig.entityPath !== queueOrTopicName) {\n throw new Error(entityPathMisMatchError);\n }\n}\n"]}
|