@azure/event-hubs 5.13.0-alpha.20241004.1 → 5.13.0-alpha.20241011.1
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/eventData.d.ts +12 -1
- package/dist/browser/eventData.d.ts.map +1 -1
- package/dist/browser/eventData.js +35 -1
- package/dist/browser/eventData.js.map +1 -1
- package/dist/browser/eventDataBatch.d.ts.map +1 -1
- package/dist/browser/eventDataBatch.js +4 -1
- package/dist/browser/eventDataBatch.js.map +1 -1
- package/dist/browser/eventHubProducerClient.d.ts.map +1 -1
- package/dist/browser/eventHubProducerClient.js +2 -0
- package/dist/browser/eventHubProducerClient.js.map +1 -1
- package/dist/browser/eventHubSender.d.ts.map +1 -1
- package/dist/browser/eventHubSender.js +3 -3
- package/dist/browser/eventHubSender.js.map +1 -1
- package/dist/browser/partitionReceiver.js +2 -2
- package/dist/browser/partitionReceiver.js.map +1 -1
- package/dist/browser/util/constants.d.ts +2 -0
- package/dist/browser/util/constants.d.ts.map +1 -1
- package/dist/browser/util/constants.js +3 -1
- package/dist/browser/util/constants.js.map +1 -1
- package/dist/commonjs/eventData.d.ts +12 -1
- package/dist/commonjs/eventData.d.ts.map +1 -1
- package/dist/commonjs/eventData.js +37 -1
- package/dist/commonjs/eventData.js.map +1 -1
- package/dist/commonjs/eventDataBatch.d.ts.map +1 -1
- package/dist/commonjs/eventDataBatch.js +3 -0
- package/dist/commonjs/eventDataBatch.js.map +1 -1
- package/dist/commonjs/eventHubProducerClient.d.ts.map +1 -1
- package/dist/commonjs/eventHubProducerClient.js +2 -0
- package/dist/commonjs/eventHubProducerClient.js.map +1 -1
- package/dist/commonjs/eventHubSender.d.ts.map +1 -1
- package/dist/commonjs/eventHubSender.js +1 -1
- package/dist/commonjs/eventHubSender.js.map +1 -1
- package/dist/commonjs/partitionReceiver.js +1 -1
- package/dist/commonjs/partitionReceiver.js.map +1 -1
- package/dist/commonjs/util/constants.d.ts +2 -0
- package/dist/commonjs/util/constants.d.ts.map +1 -1
- package/dist/commonjs/util/constants.js +4 -2
- package/dist/commonjs/util/constants.js.map +1 -1
- package/dist/esm/eventData.d.ts +12 -1
- package/dist/esm/eventData.d.ts.map +1 -1
- package/dist/esm/eventData.js +35 -1
- package/dist/esm/eventData.js.map +1 -1
- package/dist/esm/eventDataBatch.d.ts.map +1 -1
- package/dist/esm/eventDataBatch.js +4 -1
- package/dist/esm/eventDataBatch.js.map +1 -1
- package/dist/esm/eventHubProducerClient.d.ts.map +1 -1
- package/dist/esm/eventHubProducerClient.js +2 -0
- package/dist/esm/eventHubProducerClient.js.map +1 -1
- package/dist/esm/eventHubSender.d.ts.map +1 -1
- package/dist/esm/eventHubSender.js +3 -3
- package/dist/esm/eventHubSender.js.map +1 -1
- package/dist/esm/partitionReceiver.js +2 -2
- package/dist/esm/partitionReceiver.js.map +1 -1
- package/dist/esm/util/constants.d.ts +2 -0
- package/dist/esm/util/constants.d.ts.map +1 -1
- package/dist/esm/util/constants.js +3 -1
- package/dist/esm/util/constants.js.map +1 -1
- package/dist/event-hubs.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventHubSender.js","sourceRoot":"","sources":["../../src/eventHubSender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAOL,OAAO,EACP,KAAK,GACN,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,wBAAwB,EAExB,kBAAkB,EAElB,sBAAsB,EACtB,KAAK,EACL,KAAK,EACL,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,oCAAoC,EACpC,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAsC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EAEN,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAMrB,O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,MAAM,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n AmqpError,\n AwaitableSender,\n AwaitableSenderOptions,\n EventContext,\n OnAmqpEvent,\n Message as RheaMessage,\n message,\n types,\n} from \"rhea-promise\";\nimport {\n Constants,\n ErrorNameConditionMapper,\n RetryConfig,\n RetryOperationType,\n RetryOptions,\n defaultCancellableLock,\n delay,\n retry,\n translate,\n} from \"@azure/core-amqp\";\nimport {\n EventData,\n EventDataInternal,\n populateIdempotentMessageAnnotations,\n toRheaMessage,\n} from \"./eventData.js\";\nimport { EventDataBatch, EventDataBatchImpl, isEventDataBatch } from \"./eventDataBatch.js\";\nimport {\n logErrorStackTrace,\n createSimpleLogger,\n logger,\n SimpleLogger,\n createSenderLogPrefix,\n} from \"./logger.js\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { ConnectionContext } from \"./connectionContext.js\";\nimport { EventHubProducerOptions, IdempotentLinkProperties } from \"./models/private.js\";\nimport { SendOptions } from \"./models/public.js\";\nimport { PartitionPublishingOptions, PartitionPublishingProperties } from \"./models/private.js\";\nimport { getRetryAttemptTimeoutInMs } from \"./util/retries.js\";\nimport {\n idempotentProducerAmqpPropertyNames,\n PENDING_PUBLISH_SEQ_NUM_SYMBOL,\n} from \"./util/constants.js\";\nimport { isDefined } from \"@azure/core-util\";\nimport { translateError } from \"./util/error.js\";\nimport { TimerLoop } from \"./util/timerLoop.js\";\nimport { withAuth } from \"./withAuth.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\n/**\n * @internal\n */\nexport interface EventHubSenderOptions {\n /**\n * Indicates whether or not the sender should enable idempotent publishing to Event Hub partitions.\n */\n enableIdempotentProducer: boolean;\n /**\n * The EventHub partition id to which the sender wants to send the event data.\n */\n partitionId?: string;\n /**\n * The set of options that can be specified to influence publishing behavior\n * specific to a partition.\n */\n partitionPublishingOptions?: PartitionPublishingOptions;\n}\n\n/**\n * Describes the EventHubSender that will send event data to EventHub.\n * @internal\n */\nexport class EventHubSender {\n /**\n * The unique lock name per connection that is used to acquire the\n * lock for establishing a sender link by an entity on that connection.\n */\n private readonly senderLock: string = getRandomName(\"sender\");\n /**\n * The handler function to handle errors that happen on the\n * underlying sender.\n */\n private readonly _onAmqpError: OnAmqpEvent;\n /**\n * The handler function to handle \"sender_close\" event\n * that happens on the underlying sender.\n */\n private readonly _onAmqpClose: OnAmqpEvent;\n /**\n * The message handler that will be set as the handler on\n * the underlying rhea sender's session for the \"session_error\" event.\n */\n private _onSessionError: OnAmqpEvent;\n /**\n * The message handler that will be set as the handler on\n * the underlying rhea sender's session for the \"session_close\" event.\n */\n private _onSessionClose: OnAmqpEvent;\n /**\n * The AMQP sender link.\n */\n private _sender?: AwaitableSender;\n /**\n * The partition ID.\n */\n private readonly partitionId?: string;\n /**\n * Indicates whether the sender is configured for idempotent publishing.\n */\n private _isIdempotentProducer: boolean;\n /**\n * Indicates whether the sender has an in-flight send while idempotent\n * publishing is enabled.\n */\n private _hasPendingSend?: boolean;\n /**\n * A local copy of the PartitionPublishingProperties that can be mutated to\n * keep track of the lastSequenceNumber used.\n */\n private _localPublishingProperties?: PartitionPublishingProperties;\n /**\n * The user-provided set of options that can be specified to influence\n * publishing behavior specific to a partition.\n */\n private _userProvidedPublishingOptions?: PartitionPublishingOptions;\n /**\n * Indicates whether the link is in the process of connecting\n * (establishing) itself. Default value: `false`.\n */\n private isConnecting: boolean = false;\n /**\n * The unique name for the entity (mostly a guid).\n */\n private readonly name: string;\n /**\n * The address in the following form:\n * - `\"<hubName>\"`\n * - `\"<hubName>/Partitions/<partitionId>\"`.\n */\n private readonly address: string;\n /**\n * The token audience in the following form:\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>/Partitions/<partitionId>\"`.\n */\n private readonly audience: string;\n /**\n * Provides relevant information about the amqp connection,\n * cbs and $management sessions, token provider, sender and receivers.\n */\n private readonly _context: ConnectionContext;\n /**\n * The auth loop.\n */\n private authLoop?: TimerLoop;\n /**\n * The logger.\n */\n private readonly logger: SimpleLogger;\n\n /** The client identifier */\n private _id: string;\n\n /**\n * Creates a new EventHubSender instance.\n * @param context - The connection context.\n * @param options - Options used to configure the EventHubSender.\n */\n constructor(\n context: ConnectionContext,\n senderId: string,\n { partitionId, enableIdempotentProducer, partitionPublishingOptions }: EventHubSenderOptions,\n ) {\n this.address = context.config.getSenderAddress(partitionId);\n this.name = this.address;\n this._id = senderId;\n this.audience = context.config.getSenderAudience(partitionId);\n this._context = context;\n this.partitionId = partitionId;\n this._isIdempotentProducer = enableIdempotentProducer;\n this._userProvidedPublishingOptions = partitionPublishingOptions;\n const logPrefix = createSenderLogPrefix(this.name, this._context.connectionId);\n this.logger = createSimpleLogger(logger, logPrefix);\n\n this._onAmqpError = (eventContext: EventContext) => {\n const senderError = eventContext.sender && eventContext.sender.error;\n this.logger.verbose(\n \"'sender_error' event occurred. The associated error is: %O\",\n senderError,\n );\n // TODO: Consider rejecting promise in trySendBatch() or createBatch()\n };\n\n this._onSessionError = (eventContext: EventContext) => {\n const sessionError = eventContext.session && eventContext.session.error;\n this.logger.verbose(\n \"'session_error' event occurred. The associated error is: %O\",\n sessionError,\n );\n // TODO: Consider rejecting promise in trySendBatch() or createBatch()\n };\n\n this._onAmqpClose = async (eventContext: EventContext) => {\n const sender = this._sender || eventContext.sender!;\n this.logger.verbose(\n \"'sender_close' event occurred. Value for isItselfClosed on the receiver is: '%s' \" +\n \"Value for isConnecting on the session is: '%s'.\",\n sender?.isItselfClosed().toString(),\n this.isConnecting,\n );\n if (sender && !this.isConnecting) {\n // Call close to clean up timers & other resources\n await sender.close().catch((err) => {\n this.logger.verbose(\"error when closing after 'sender_close' event: %O\", err);\n });\n }\n };\n\n this._onSessionClose = async (eventContext: EventContext) => {\n const sender = this._sender || eventContext.sender!;\n this.logger.verbose(\n \"'session_close' event occurred. Value for isSessionItselfClosed on the session is: '%s' \" +\n \"Value for isConnecting on the session is: '%s'.\",\n sender?.isSessionItselfClosed().toString(),\n this.isConnecting,\n );\n if (sender && !this.isConnecting) {\n // Call close to clean up timers & other resources\n await sender.close().catch((err) => {\n this.logger.verbose(\"error when closing after 'session_close' event: %O\", err);\n });\n }\n };\n }\n\n /**\n * Deletes the sender from the context. Clears the token renewal timer. Closes the sender link.\n */\n async close(): Promise<void> {\n try {\n if (this._sender) {\n this.logger.info(\"closing\");\n const senderLink = this._sender;\n this._deleteFromCache();\n await senderLink.close();\n this.authLoop?.stop();\n this.logger.verbose(\"closed.\");\n }\n } catch (err: any) {\n const msg = `an error occurred while closing: ${err?.name}: ${err?.message}`;\n this.logger.warning(msg);\n logErrorStackTrace(err);\n throw err;\n }\n }\n\n /**\n * Determines whether the AMQP sender link is open. If open then returns true else returns false.\n * @returns boolean\n */\n isOpen(): boolean {\n const result = Boolean(this._sender && this._sender.isOpen());\n this.logger.verbose(\"is open? -> %s\", result);\n return result;\n }\n /**\n * Returns maximum message size on the AMQP sender link.\n * @param abortSignal - An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation.\n * For example, use the @azure/abort-controller to create an `AbortSignal`.\n * @returns Promise<number>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n async getMaxMessageSize(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<number> {\n const sender = await this._getLink(options);\n\n return sender.maxMessageSize;\n }\n\n /**\n * Get the information about the state of publishing for a partition as observed by the `EventHubSender`.\n * This data can always be read, but will only be populated with information relevant to the active features\n * for the producer client.\n */\n async getPartitionPublishingProperties(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<PartitionPublishingProperties> {\n if (this._localPublishingProperties) {\n // Send a copy of the properties so it can't be mutated downstream.\n return { ...this._localPublishingProperties };\n }\n\n const properties: PartitionPublishingProperties = {\n isIdempotentPublishingEnabled: this._isIdempotentProducer,\n partitionId: this.partitionId ?? \"\",\n };\n\n if (this._isIdempotentProducer) {\n this._sender = await this._getLink(options);\n // await this._createLinkIfNotOpen(options);\n if (!this._sender) {\n // createLinkIfNotOpen should throw if `this._sender` can't be created, but just in case it gets\n // deleted while setting up token refreshing, make sure it exists.\n throw new Error(\n `Failed to retrieve partition publishing properties for partition \"${this.partitionId}\".`,\n );\n }\n\n const {\n [idempotentProducerAmqpPropertyNames.epoch]: ownerLevel,\n [idempotentProducerAmqpPropertyNames.producerId]: producerGroupId,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: lastPublishedSequenceNumber,\n } = this._sender.properties ?? {};\n\n properties.ownerLevel = parseInt(ownerLevel, 10);\n properties.producerGroupId = parseInt(producerGroupId, 10);\n properties.lastPublishedSequenceNumber = parseInt(lastPublishedSequenceNumber, 10);\n }\n\n this._localPublishingProperties = properties;\n\n // Send a copy of the properties so it can't be mutated downstream.\n return { ...properties };\n }\n\n /**\n * Send a batch of EventData to the EventHub. The \"message_annotations\",\n * \"application_properties\" and \"properties\" of the first message will be set as that\n * of the envelope (batch message).\n * @param events - An array of EventData objects to be sent in a Batch message.\n * @param options - Options to control the way the events are batched along with request options\n */\n async send(\n events: EventData[] | EventDataBatch,\n options?: SendOptions &\n EventHubProducerOptions & { tracingProperties?: Array<EventData[\"properties\"]> },\n ): Promise<void> {\n try {\n this.logger.info(\"trying to send EventData[].\");\n if (this._isIdempotentProducer && this._hasPendingSend) {\n throw new Error(\n `There can only be 1 \"sendBatch\" call in-flight per partition while \"enableIdempotentRetries\" is set to true.`,\n );\n }\n\n const eventCount = isEventDataBatch(events) ? events.count : events.length;\n if (eventCount === 0) {\n this.logger.info(`no events were passed to sendBatch.`);\n return;\n }\n\n if (this._isIdempotentProducer) {\n this._hasPendingSend = true;\n }\n\n this.logger.info(\"sending encoded batch message.\");\n await this._trySendBatch(events, options);\n if (this._isIdempotentProducer) {\n commitIdempotentSequenceNumbers(events);\n if (this._localPublishingProperties) {\n const { lastPublishedSequenceNumber = 0 } = this._localPublishingProperties;\n // Increment the lastPublishedSequenceNumber based on the number of events published.\n this._localPublishingProperties.lastPublishedSequenceNumber =\n lastPublishedSequenceNumber + eventCount;\n }\n }\n return;\n } catch (err: any) {\n rollbackIdempotentSequenceNumbers(events);\n this.logger.warning(\n `an error occurred while sending the batch message ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n throw err;\n } finally {\n if (this._isIdempotentProducer) {\n this._hasPendingSend = false;\n }\n }\n }\n\n /**\n * @param sender - The rhea sender that contains the idempotent producer properties.\n */\n private _populateLocalPublishingProperties(sender: AwaitableSender): void {\n const {\n [idempotentProducerAmqpPropertyNames.epoch]: ownerLevel,\n [idempotentProducerAmqpPropertyNames.producerId]: producerGroupId,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: lastPublishedSequenceNumber,\n } = sender.properties ?? {};\n\n this._localPublishingProperties = {\n isIdempotentPublishingEnabled: this._isIdempotentProducer,\n partitionId: this.partitionId ?? \"\",\n lastPublishedSequenceNumber,\n ownerLevel,\n producerGroupId,\n };\n }\n\n private _deleteFromCache(): void {\n this._sender = undefined;\n delete this._context.senders[this.name];\n this.logger.verbose(\"deleted from the client cache.\");\n }\n\n private _createSenderOptions(): AwaitableSenderOptions {\n const srOptions: AwaitableSenderOptions = {\n name: this.name,\n source: this._id,\n target: {\n address: this.address,\n },\n onError: this._onAmqpError,\n onClose: this._onAmqpClose,\n onSessionError: this._onSessionError,\n onSessionClose: this._onSessionClose,\n };\n\n srOptions.desired_capabilities = [Constants.geoReplication];\n if (this._isIdempotentProducer) {\n srOptions.desired_capabilities.push(idempotentProducerAmqpPropertyNames.capability);\n const idempotentProperties = generateIdempotentLinkProperties(\n this._userProvidedPublishingOptions,\n this._localPublishingProperties,\n );\n srOptions.properties = idempotentProperties;\n }\n this.logger.verbose(\"being created with options: %O\", srOptions);\n return srOptions;\n }\n\n /**\n * Tries to send the message to EventHub if there is enough credit to send them\n * and the circular buffer has available space to settle the message after sending them.\n *\n * We have implemented a synchronous send over here in the sense that we shall be waiting\n * for the message to be accepted or rejected and accordingly resolve or reject the promise.\n * @param rheaMessage - The message to be sent to EventHub.\n * @returns Promise<void>\n */\n private async _trySendBatch(\n events: EventData[] | EventDataBatch,\n options: SendOptions &\n EventHubProducerOptions & {\n /**\n * Tracing properties that are associated with EventData.\n */\n tracingProperties?: Array<EventData[\"properties\"]>;\n } = {},\n ): Promise<void> {\n const abortSignal: AbortSignalLike | undefined = options.abortSignal;\n const retryOptions = options.retryOptions || {};\n const timeoutInMs = getRetryAttemptTimeoutInMs(retryOptions);\n retryOptions.timeoutInMs = timeoutInMs;\n\n const sendEventPromise = async (): Promise<void> => {\n const initStartTime = Date.now();\n // TODO: (jeremymeng) A or B\n // variant A:\n const sender = await this._getLink(options);\n // variant B\n // await this._createLinkIfNotOpen(options);\n const publishingProps = await this.getPartitionPublishingProperties(options);\n const timeTakenByInit = Date.now() - initStartTime;\n\n this.logger.verbose(\n \"credit: %d available: %d\",\n sender.credit,\n sender.session.outgoing.available(),\n );\n\n let waitTimeForSendable = 1000;\n if (!sender.sendable() && timeoutInMs - timeTakenByInit > waitTimeForSendable) {\n this.logger.verbose(\"waiting for 1 second for sender to become sendable\");\n\n await delay(waitTimeForSendable);\n\n this.logger.verbose(\n \"after waiting for a second, credit: %d available: %d\",\n sender.credit,\n sender.session?.outgoing?.available(),\n );\n } else {\n waitTimeForSendable = 0;\n }\n\n if (!sender.sendable()) {\n // let us retry to send the message after some time.\n const msg = `cannot send the message right now. Please try later.`;\n this.logger.warning(msg);\n const amqpError: AmqpError = {\n condition: ErrorNameConditionMapper.SenderBusyError,\n description: msg,\n };\n throw translate(amqpError);\n }\n\n if (timeoutInMs <= timeTakenByInit + waitTimeForSendable) {\n const desc: string =\n `was not able to send the message right now, due ` + `to operation timeout.`;\n this.logger.warning(desc);\n const e: AmqpError = {\n condition: ErrorNameConditionMapper.ServiceUnavailableError,\n description: desc,\n };\n throw translate(e);\n }\n\n try {\n const encodedMessage = transformEventsForSend(events, publishingProps, options);\n const delivery = await sender.send(encodedMessage, {\n format: 0x80013700,\n timeoutInSeconds: (timeoutInMs - timeTakenByInit - waitTimeForSendable) / 1000,\n abortSignal,\n });\n this.logger.info(\"sent message with delivery id: %d\", delivery.id);\n } catch (err: any) {\n const error = err.innerError || err;\n const translatedError = translateError(error);\n throw translatedError;\n }\n };\n\n const config: RetryConfig<void> = {\n operation: sendEventPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.sendMessage,\n abortSignal: abortSignal,\n retryOptions: retryOptions,\n };\n\n try {\n await retry<void>(config);\n } catch (err: any) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while sending the message %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n private async _getLink(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<AwaitableSender> {\n if (this.isOpen() && this._sender) {\n return this._sender;\n }\n const retryOptions = options.retryOptions || {};\n const timeoutInMs = getRetryAttemptTimeoutInMs(retryOptions);\n retryOptions.timeoutInMs = timeoutInMs;\n const senderOptions = this._createSenderOptions();\n\n const startTime = Date.now();\n const createLinkPromise = async (): Promise<AwaitableSender> => {\n return defaultCancellableLock.acquire(\n this.senderLock,\n () => {\n const taskStartTime = Date.now();\n const taskTimeoutInMs = timeoutInMs - (taskStartTime - startTime);\n return this._init({\n ...senderOptions,\n abortSignal: options.abortSignal,\n timeoutInMs: taskTimeoutInMs,\n });\n },\n { abortSignal: options.abortSignal, timeoutInMs: timeoutInMs },\n );\n };\n\n const config: RetryConfig<AwaitableSender> = {\n operation: createLinkPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.senderLink,\n abortSignal: options.abortSignal,\n retryOptions: retryOptions,\n };\n\n try {\n return await retry<AwaitableSender>(config);\n } catch (err: any) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while creating: %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Initializes the sender session on the connection.\n * Should only be called from _createLinkIfNotOpen\n */\n private async _init(\n options: AwaitableSenderOptions & {\n abortSignal: AbortSignalLike | undefined;\n timeoutInMs: number;\n },\n ): Promise<AwaitableSender> {\n const createSender = async () => {\n this.logger.verbose(\"trying to be created...\");\n\n const sender = await this._context.connection.createAwaitableSender(options);\n this._sender = sender;\n this._populateLocalPublishingProperties(this._sender);\n this.isConnecting = false;\n this.logger.verbose(\"created with options: %O\", options);\n\n // It is possible for someone to close the sender and then start it again.\n // Thus make sure that the sender is present in the client cache.\n if (!this._context.senders[this.name]) this._context.senders[this.name] = this;\n };\n try {\n if (!this.isOpen() || !this._sender) {\n await this._context.readyToOpenLink();\n this.authLoop = await withAuth(\n createSender,\n this._context,\n this.audience,\n options.timeoutInMs,\n this.logger,\n { abortSignal: options.abortSignal },\n );\n // it is guaranteed to be defined at this point, otherwise, an error would\n // have been thrown.\n return this._sender!;\n } else {\n this.logger.verbose(\"is open -> %s. Hence not reconnecting.\", this.isOpen());\n return this._sender;\n }\n } catch (err) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while being created: %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Creates a new sender to the given event hub, and optionally to a given partition if it is\n * not present in the context or returns the one present in the context.\n * @hidden\n * @param options - Options used to configure the EventHubSender.\n */\n static create(\n context: ConnectionContext,\n senderId: string,\n options: EventHubSenderOptions,\n ): EventHubSender {\n const ehSender: EventHubSender = new EventHubSender(context, senderId, options);\n if (!context.senders[ehSender.name]) {\n context.senders[ehSender.name] = ehSender;\n }\n return context.senders[ehSender.name];\n }\n}\n\n/**\n * Generates the link properties for an indemopotent sender given\n * based on the user-provided and locally-cached publishing options.\n *\n * Note: The set of idempotent properties a user specifies at EventHubProducerClient instantiation-time\n * is slightly different than what the service returns and the EventHubSender keeps track of locally.\n *\n * The difference is that the user specifies the `startingSequenceNumber`, whereas the local options\n * (those returned by getPartitionPublishingProperties) specifies `lastPublishedSequenceNumber`.\n *\n * These _can_ be the same, but the user is technically free to set any `startingSequenceNumber` they want.\n * @internal\n */\nexport function generateIdempotentLinkProperties(\n userProvidedPublishingOptions: PartitionPublishingOptions | undefined,\n localPublishingOptions: PartitionPublishingProperties | undefined,\n): IdempotentLinkProperties | Record<string, never> {\n let ownerLevel: number | undefined;\n let producerGroupId: number | undefined;\n let sequenceNumber: number | undefined;\n\n // Prefer local publishing options since this is the up-to-date state of the sender.\n // Only use user-provided publishing options the first time we create the link.\n if (localPublishingOptions) {\n ownerLevel = localPublishingOptions.ownerLevel;\n producerGroupId = localPublishingOptions.producerGroupId;\n sequenceNumber = localPublishingOptions.lastPublishedSequenceNumber;\n } else if (userProvidedPublishingOptions) {\n ownerLevel = userProvidedPublishingOptions.ownerLevel;\n producerGroupId = userProvidedPublishingOptions.producerGroupId;\n sequenceNumber = userProvidedPublishingOptions.startingSequenceNumber;\n } else {\n // If we don't have any properties at all, send an empty object.\n // This will cause the service to generate a new producer-id for our client.\n return {};\n }\n\n // The service requires that if ANY_ of these properties are defined,\n // they _ALL_ have to be defined.\n // If we don't have one of the required values, use `null` and the\n // service will provide it.\n const idempotentLinkProperties: IdempotentLinkProperties = {\n [idempotentProducerAmqpPropertyNames.epoch]: isDefined(ownerLevel)\n ? types.wrap_short(ownerLevel)\n : null,\n [idempotentProducerAmqpPropertyNames.producerId]: isDefined(producerGroupId)\n ? types.wrap_long(producerGroupId)\n : null,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: isDefined(sequenceNumber)\n ? types.wrap_int(sequenceNumber)\n : null,\n };\n\n return idempotentLinkProperties;\n}\n\n/**\n * Encodes a list or batch of events into a single binary message that can be sent to the service.\n *\n * Prior to encoding, any special properties not specified by the user, such as tracing or idempotent\n * properties, are assigned to the list or batch of events as needed.\n *\n * @internal\n * @param events - Events to transform for sending to the service.\n * @param publishingProps - Describes the current publishing state for the partition.\n * @param options - Options used to configure this function.\n */\nexport function transformEventsForSend(\n events: EventData[] | EventDataBatch,\n publishingProps: PartitionPublishingProperties,\n options: SendOptions & {\n /**\n * A list containing the `Diagnostic-Id` tracing property that is associated with each EventData.\n * The index of tracingProperties corresponds to the same index in `events` when `events` is EventData[].\n */\n tracingProperties?: Array<EventData[\"properties\"]>;\n } = {},\n): Buffer {\n if (isEventDataBatch(events)) {\n return (events as EventDataBatchImpl)._generateMessage(publishingProps);\n } else {\n const eventCount = events.length;\n // convert events to rhea messages\n const rheaMessages: RheaMessage[] = [];\n const tracingProperties = options.tracingProperties ?? [];\n for (let i = 0; i < eventCount; i++) {\n const originalEvent = events[i];\n const tracingProperty = tracingProperties[i];\n // Create a copy of the user's event so we can add the tracing property.\n const event: EventData = {\n ...originalEvent,\n properties: { ...originalEvent.properties, ...tracingProperty },\n };\n const rheaMessage = toRheaMessage(event, options.partitionKey);\n\n // populate idempotent message annotations\n const { lastPublishedSequenceNumber = 0 } = publishingProps;\n const startingSequenceNumber = lastPublishedSequenceNumber + 1;\n const pendingPublishSequenceNumber = startingSequenceNumber + i;\n populateIdempotentMessageAnnotations(rheaMessage, {\n ...publishingProps,\n publishSequenceNumber: pendingPublishSequenceNumber,\n });\n\n if (publishingProps.isIdempotentPublishingEnabled) {\n // Set pending seq number on user's event.\n (originalEvent as EventDataInternal)[PENDING_PUBLISH_SEQ_NUM_SYMBOL] =\n pendingPublishSequenceNumber;\n }\n\n rheaMessages.push(rheaMessage);\n }\n\n // Encode every amqp message and then convert every encoded message to amqp data section\n const batchMessage: RheaMessage = {\n body: message.data_sections(rheaMessages.map(message.encode)),\n };\n\n // Set message_annotations of the first message as\n // that of the envelope (batch message).\n if (rheaMessages[0].message_annotations) {\n batchMessage.message_annotations = { ...rheaMessages[0].message_annotations };\n }\n\n // Finally encode the envelope (batch message).\n return message.encode(batchMessage);\n }\n}\n\n/**\n * Commits the pending publish sequence number events.\n * EventDataBatch exposes this as `startingPublishSequenceNumber`,\n * EventData not in a batch exposes this as `publishedSequenceNumber`.\n */\nfunction commitIdempotentSequenceNumbers(\n events: Omit<EventDataInternal, \"getRawAmqpMessage\">[] | EventDataBatch,\n): void {\n if (isEventDataBatch(events)) {\n (events as EventDataBatchImpl)._commitPublish();\n } else {\n // For each event, set the `publishedSequenceNumber` equal to the sequence number\n // we set when we attempted to send the events to the service.\n for (const event of events) {\n event._publishedSequenceNumber = event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n delete event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n }\n }\n}\n\n/**\n * Rolls back any pending publish sequence number in the events.\n */\nfunction rollbackIdempotentSequenceNumbers(\n events: Omit<EventDataInternal, \"getRawAmqpMessage\">[] | EventDataBatch,\n): void {\n if (isEventDataBatch(events)) {\n /* No action required. */\n } else {\n for (const event of events) {\n delete event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"eventHubSender.js","sourceRoot":"","sources":["../../src/eventHubSender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAOL,OAAO,EACP,KAAK,GACN,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,EAExB,kBAAkB,EAElB,sBAAsB,EACtB,KAAK,EACL,KAAK,EACL,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,oCAAoC,EACpC,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAsC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EAEN,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAMrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;A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8B,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n AmqpError,\n AwaitableSender,\n AwaitableSenderOptions,\n EventContext,\n OnAmqpEvent,\n Message as RheaMessage,\n message,\n types,\n} from \"rhea-promise\";\nimport {\n ErrorNameConditionMapper,\n RetryConfig,\n RetryOperationType,\n RetryOptions,\n defaultCancellableLock,\n delay,\n retry,\n translate,\n} from \"@azure/core-amqp\";\nimport {\n EventData,\n EventDataInternal,\n populateIdempotentMessageAnnotations,\n toRheaMessage,\n} from \"./eventData.js\";\nimport { EventDataBatch, EventDataBatchImpl, isEventDataBatch } from \"./eventDataBatch.js\";\nimport {\n logErrorStackTrace,\n createSimpleLogger,\n logger,\n SimpleLogger,\n createSenderLogPrefix,\n} from \"./logger.js\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { ConnectionContext } from \"./connectionContext.js\";\nimport { EventHubProducerOptions, IdempotentLinkProperties } from \"./models/private.js\";\nimport { SendOptions } from \"./models/public.js\";\nimport { PartitionPublishingOptions, PartitionPublishingProperties } from \"./models/private.js\";\nimport { getRetryAttemptTimeoutInMs } from \"./util/retries.js\";\nimport {\n idempotentProducerAmqpPropertyNames,\n PENDING_PUBLISH_SEQ_NUM_SYMBOL,\n geoReplication,\n} from \"./util/constants.js\";\nimport { isDefined } from \"@azure/core-util\";\nimport { translateError } from \"./util/error.js\";\nimport { TimerLoop } from \"./util/timerLoop.js\";\nimport { withAuth } from \"./withAuth.js\";\nimport { getRandomName } from \"./util/utils.js\";\n\n/**\n * @internal\n */\nexport interface EventHubSenderOptions {\n /**\n * Indicates whether or not the sender should enable idempotent publishing to Event Hub partitions.\n */\n enableIdempotentProducer: boolean;\n /**\n * The EventHub partition id to which the sender wants to send the event data.\n */\n partitionId?: string;\n /**\n * The set of options that can be specified to influence publishing behavior\n * specific to a partition.\n */\n partitionPublishingOptions?: PartitionPublishingOptions;\n}\n\n/**\n * Describes the EventHubSender that will send event data to EventHub.\n * @internal\n */\nexport class EventHubSender {\n /**\n * The unique lock name per connection that is used to acquire the\n * lock for establishing a sender link by an entity on that connection.\n */\n private readonly senderLock: string = getRandomName(\"sender\");\n /**\n * The handler function to handle errors that happen on the\n * underlying sender.\n */\n private readonly _onAmqpError: OnAmqpEvent;\n /**\n * The handler function to handle \"sender_close\" event\n * that happens on the underlying sender.\n */\n private readonly _onAmqpClose: OnAmqpEvent;\n /**\n * The message handler that will be set as the handler on\n * the underlying rhea sender's session for the \"session_error\" event.\n */\n private _onSessionError: OnAmqpEvent;\n /**\n * The message handler that will be set as the handler on\n * the underlying rhea sender's session for the \"session_close\" event.\n */\n private _onSessionClose: OnAmqpEvent;\n /**\n * The AMQP sender link.\n */\n private _sender?: AwaitableSender;\n /**\n * The partition ID.\n */\n private readonly partitionId?: string;\n /**\n * Indicates whether the sender is configured for idempotent publishing.\n */\n private _isIdempotentProducer: boolean;\n /**\n * Indicates whether the sender has an in-flight send while idempotent\n * publishing is enabled.\n */\n private _hasPendingSend?: boolean;\n /**\n * A local copy of the PartitionPublishingProperties that can be mutated to\n * keep track of the lastSequenceNumber used.\n */\n private _localPublishingProperties?: PartitionPublishingProperties;\n /**\n * The user-provided set of options that can be specified to influence\n * publishing behavior specific to a partition.\n */\n private _userProvidedPublishingOptions?: PartitionPublishingOptions;\n /**\n * Indicates whether the link is in the process of connecting\n * (establishing) itself. Default value: `false`.\n */\n private isConnecting: boolean = false;\n /**\n * The unique name for the entity (mostly a guid).\n */\n private readonly name: string;\n /**\n * The address in the following form:\n * - `\"<hubName>\"`\n * - `\"<hubName>/Partitions/<partitionId>\"`.\n */\n private readonly address: string;\n /**\n * The token audience in the following form:\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>\"`\n * - `\"sb://<yournamespace>.servicebus.windows.net/<hubName>/Partitions/<partitionId>\"`.\n */\n private readonly audience: string;\n /**\n * Provides relevant information about the amqp connection,\n * cbs and $management sessions, token provider, sender and receivers.\n */\n private readonly _context: ConnectionContext;\n /**\n * The auth loop.\n */\n private authLoop?: TimerLoop;\n /**\n * The logger.\n */\n private readonly logger: SimpleLogger;\n\n /** The client identifier */\n private _id: string;\n\n /**\n * Creates a new EventHubSender instance.\n * @param context - The connection context.\n * @param options - Options used to configure the EventHubSender.\n */\n constructor(\n context: ConnectionContext,\n senderId: string,\n { partitionId, enableIdempotentProducer, partitionPublishingOptions }: EventHubSenderOptions,\n ) {\n this.address = context.config.getSenderAddress(partitionId);\n this.name = this.address;\n this._id = senderId;\n this.audience = context.config.getSenderAudience(partitionId);\n this._context = context;\n this.partitionId = partitionId;\n this._isIdempotentProducer = enableIdempotentProducer;\n this._userProvidedPublishingOptions = partitionPublishingOptions;\n const logPrefix = createSenderLogPrefix(this.name, this._context.connectionId);\n this.logger = createSimpleLogger(logger, logPrefix);\n\n this._onAmqpError = (eventContext: EventContext) => {\n const senderError = eventContext.sender && eventContext.sender.error;\n this.logger.verbose(\n \"'sender_error' event occurred. The associated error is: %O\",\n senderError,\n );\n // TODO: Consider rejecting promise in trySendBatch() or createBatch()\n };\n\n this._onSessionError = (eventContext: EventContext) => {\n const sessionError = eventContext.session && eventContext.session.error;\n this.logger.verbose(\n \"'session_error' event occurred. The associated error is: %O\",\n sessionError,\n );\n // TODO: Consider rejecting promise in trySendBatch() or createBatch()\n };\n\n this._onAmqpClose = async (eventContext: EventContext) => {\n const sender = this._sender || eventContext.sender!;\n this.logger.verbose(\n \"'sender_close' event occurred. Value for isItselfClosed on the receiver is: '%s' \" +\n \"Value for isConnecting on the session is: '%s'.\",\n sender?.isItselfClosed().toString(),\n this.isConnecting,\n );\n if (sender && !this.isConnecting) {\n // Call close to clean up timers & other resources\n await sender.close().catch((err) => {\n this.logger.verbose(\"error when closing after 'sender_close' event: %O\", err);\n });\n }\n };\n\n this._onSessionClose = async (eventContext: EventContext) => {\n const sender = this._sender || eventContext.sender!;\n this.logger.verbose(\n \"'session_close' event occurred. Value for isSessionItselfClosed on the session is: '%s' \" +\n \"Value for isConnecting on the session is: '%s'.\",\n sender?.isSessionItselfClosed().toString(),\n this.isConnecting,\n );\n if (sender && !this.isConnecting) {\n // Call close to clean up timers & other resources\n await sender.close().catch((err) => {\n this.logger.verbose(\"error when closing after 'session_close' event: %O\", err);\n });\n }\n };\n }\n\n /**\n * Deletes the sender from the context. Clears the token renewal timer. Closes the sender link.\n */\n async close(): Promise<void> {\n try {\n if (this._sender) {\n this.logger.info(\"closing\");\n const senderLink = this._sender;\n this._deleteFromCache();\n await senderLink.close();\n this.authLoop?.stop();\n this.logger.verbose(\"closed.\");\n }\n } catch (err: any) {\n const msg = `an error occurred while closing: ${err?.name}: ${err?.message}`;\n this.logger.warning(msg);\n logErrorStackTrace(err);\n throw err;\n }\n }\n\n /**\n * Determines whether the AMQP sender link is open. If open then returns true else returns false.\n * @returns boolean\n */\n isOpen(): boolean {\n const result = Boolean(this._sender && this._sender.isOpen());\n this.logger.verbose(\"is open? -> %s\", result);\n return result;\n }\n /**\n * Returns maximum message size on the AMQP sender link.\n * @param abortSignal - An implementation of the `AbortSignalLike` interface to signal the request to cancel the operation.\n * For example, use the @azure/abort-controller to create an `AbortSignal`.\n * @returns Promise<number>\n * @throws AbortError if the operation is cancelled via the abortSignal.\n */\n async getMaxMessageSize(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<number> {\n const sender = await this._getLink(options);\n\n return sender.maxMessageSize;\n }\n\n /**\n * Get the information about the state of publishing for a partition as observed by the `EventHubSender`.\n * This data can always be read, but will only be populated with information relevant to the active features\n * for the producer client.\n */\n async getPartitionPublishingProperties(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<PartitionPublishingProperties> {\n if (this._localPublishingProperties) {\n // Send a copy of the properties so it can't be mutated downstream.\n return { ...this._localPublishingProperties };\n }\n\n const properties: PartitionPublishingProperties = {\n isIdempotentPublishingEnabled: this._isIdempotentProducer,\n partitionId: this.partitionId ?? \"\",\n };\n\n if (this._isIdempotentProducer) {\n this._sender = await this._getLink(options);\n // await this._createLinkIfNotOpen(options);\n if (!this._sender) {\n // createLinkIfNotOpen should throw if `this._sender` can't be created, but just in case it gets\n // deleted while setting up token refreshing, make sure it exists.\n throw new Error(\n `Failed to retrieve partition publishing properties for partition \"${this.partitionId}\".`,\n );\n }\n\n const {\n [idempotentProducerAmqpPropertyNames.epoch]: ownerLevel,\n [idempotentProducerAmqpPropertyNames.producerId]: producerGroupId,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: lastPublishedSequenceNumber,\n } = this._sender.properties ?? {};\n\n properties.ownerLevel = parseInt(ownerLevel, 10);\n properties.producerGroupId = parseInt(producerGroupId, 10);\n properties.lastPublishedSequenceNumber = parseInt(lastPublishedSequenceNumber, 10);\n }\n\n this._localPublishingProperties = properties;\n\n // Send a copy of the properties so it can't be mutated downstream.\n return { ...properties };\n }\n\n /**\n * Send a batch of EventData to the EventHub. The \"message_annotations\",\n * \"application_properties\" and \"properties\" of the first message will be set as that\n * of the envelope (batch message).\n * @param events - An array of EventData objects to be sent in a Batch message.\n * @param options - Options to control the way the events are batched along with request options\n */\n async send(\n events: EventData[] | EventDataBatch,\n options?: SendOptions &\n EventHubProducerOptions & { tracingProperties?: Array<EventData[\"properties\"]> },\n ): Promise<void> {\n try {\n this.logger.info(\"trying to send EventData[].\");\n if (this._isIdempotentProducer && this._hasPendingSend) {\n throw new Error(\n `There can only be 1 \"sendBatch\" call in-flight per partition while \"enableIdempotentRetries\" is set to true.`,\n );\n }\n\n const eventCount = isEventDataBatch(events) ? events.count : events.length;\n if (eventCount === 0) {\n this.logger.info(`no events were passed to sendBatch.`);\n return;\n }\n\n if (this._isIdempotentProducer) {\n this._hasPendingSend = true;\n }\n\n this.logger.info(\"sending encoded batch message.\");\n await this._trySendBatch(events, options);\n if (this._isIdempotentProducer) {\n commitIdempotentSequenceNumbers(events);\n if (this._localPublishingProperties) {\n const { lastPublishedSequenceNumber = 0 } = this._localPublishingProperties;\n // Increment the lastPublishedSequenceNumber based on the number of events published.\n this._localPublishingProperties.lastPublishedSequenceNumber =\n lastPublishedSequenceNumber + eventCount;\n }\n }\n return;\n } catch (err: any) {\n rollbackIdempotentSequenceNumbers(events);\n this.logger.warning(\n `an error occurred while sending the batch message ${err?.name}: ${err?.message}`,\n );\n logErrorStackTrace(err);\n throw err;\n } finally {\n if (this._isIdempotentProducer) {\n this._hasPendingSend = false;\n }\n }\n }\n\n /**\n * @param sender - The rhea sender that contains the idempotent producer properties.\n */\n private _populateLocalPublishingProperties(sender: AwaitableSender): void {\n const {\n [idempotentProducerAmqpPropertyNames.epoch]: ownerLevel,\n [idempotentProducerAmqpPropertyNames.producerId]: producerGroupId,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: lastPublishedSequenceNumber,\n } = sender.properties ?? {};\n\n this._localPublishingProperties = {\n isIdempotentPublishingEnabled: this._isIdempotentProducer,\n partitionId: this.partitionId ?? \"\",\n lastPublishedSequenceNumber,\n ownerLevel,\n producerGroupId,\n };\n }\n\n private _deleteFromCache(): void {\n this._sender = undefined;\n delete this._context.senders[this.name];\n this.logger.verbose(\"deleted from the client cache.\");\n }\n\n private _createSenderOptions(): AwaitableSenderOptions {\n const srOptions: AwaitableSenderOptions = {\n name: this.name,\n source: this._id,\n target: {\n address: this.address,\n },\n onError: this._onAmqpError,\n onClose: this._onAmqpClose,\n onSessionError: this._onSessionError,\n onSessionClose: this._onSessionClose,\n };\n\n srOptions.desired_capabilities = [geoReplication];\n if (this._isIdempotentProducer) {\n srOptions.desired_capabilities.push(idempotentProducerAmqpPropertyNames.capability);\n const idempotentProperties = generateIdempotentLinkProperties(\n this._userProvidedPublishingOptions,\n this._localPublishingProperties,\n );\n srOptions.properties = idempotentProperties;\n }\n this.logger.verbose(\"being created with options: %O\", srOptions);\n return srOptions;\n }\n\n /**\n * Tries to send the message to EventHub if there is enough credit to send them\n * and the circular buffer has available space to settle the message after sending them.\n *\n * We have implemented a synchronous send over here in the sense that we shall be waiting\n * for the message to be accepted or rejected and accordingly resolve or reject the promise.\n * @param rheaMessage - The message to be sent to EventHub.\n * @returns Promise<void>\n */\n private async _trySendBatch(\n events: EventData[] | EventDataBatch,\n options: SendOptions &\n EventHubProducerOptions & {\n /**\n * Tracing properties that are associated with EventData.\n */\n tracingProperties?: Array<EventData[\"properties\"]>;\n } = {},\n ): Promise<void> {\n const abortSignal: AbortSignalLike | undefined = options.abortSignal;\n const retryOptions = options.retryOptions || {};\n const timeoutInMs = getRetryAttemptTimeoutInMs(retryOptions);\n retryOptions.timeoutInMs = timeoutInMs;\n\n const sendEventPromise = async (): Promise<void> => {\n const initStartTime = Date.now();\n // TODO: (jeremymeng) A or B\n // variant A:\n const sender = await this._getLink(options);\n // variant B\n // await this._createLinkIfNotOpen(options);\n const publishingProps = await this.getPartitionPublishingProperties(options);\n const timeTakenByInit = Date.now() - initStartTime;\n\n this.logger.verbose(\n \"credit: %d available: %d\",\n sender.credit,\n sender.session.outgoing.available(),\n );\n\n let waitTimeForSendable = 1000;\n if (!sender.sendable() && timeoutInMs - timeTakenByInit > waitTimeForSendable) {\n this.logger.verbose(\"waiting for 1 second for sender to become sendable\");\n\n await delay(waitTimeForSendable);\n\n this.logger.verbose(\n \"after waiting for a second, credit: %d available: %d\",\n sender.credit,\n sender.session?.outgoing?.available(),\n );\n } else {\n waitTimeForSendable = 0;\n }\n\n if (!sender.sendable()) {\n // let us retry to send the message after some time.\n const msg = `cannot send the message right now. Please try later.`;\n this.logger.warning(msg);\n const amqpError: AmqpError = {\n condition: ErrorNameConditionMapper.SenderBusyError,\n description: msg,\n };\n throw translate(amqpError);\n }\n\n if (timeoutInMs <= timeTakenByInit + waitTimeForSendable) {\n const desc: string =\n `was not able to send the message right now, due ` + `to operation timeout.`;\n this.logger.warning(desc);\n const e: AmqpError = {\n condition: ErrorNameConditionMapper.ServiceUnavailableError,\n description: desc,\n };\n throw translate(e);\n }\n\n try {\n const encodedMessage = transformEventsForSend(events, publishingProps, options);\n const delivery = await sender.send(encodedMessage, {\n format: 0x80013700,\n timeoutInSeconds: (timeoutInMs - timeTakenByInit - waitTimeForSendable) / 1000,\n abortSignal,\n });\n this.logger.info(\"sent message with delivery id: %d\", delivery.id);\n } catch (err: any) {\n const error = err.innerError || err;\n const translatedError = translateError(error);\n throw translatedError;\n }\n };\n\n const config: RetryConfig<void> = {\n operation: sendEventPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.sendMessage,\n abortSignal: abortSignal,\n retryOptions: retryOptions,\n };\n\n try {\n await retry<void>(config);\n } catch (err: any) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while sending the message %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n private async _getLink(\n options: {\n retryOptions?: RetryOptions;\n abortSignal?: AbortSignalLike;\n } = {},\n ): Promise<AwaitableSender> {\n if (this.isOpen() && this._sender) {\n return this._sender;\n }\n const retryOptions = options.retryOptions || {};\n const timeoutInMs = getRetryAttemptTimeoutInMs(retryOptions);\n retryOptions.timeoutInMs = timeoutInMs;\n const senderOptions = this._createSenderOptions();\n\n const startTime = Date.now();\n const createLinkPromise = async (): Promise<AwaitableSender> => {\n return defaultCancellableLock.acquire(\n this.senderLock,\n () => {\n const taskStartTime = Date.now();\n const taskTimeoutInMs = timeoutInMs - (taskStartTime - startTime);\n return this._init({\n ...senderOptions,\n abortSignal: options.abortSignal,\n timeoutInMs: taskTimeoutInMs,\n });\n },\n { abortSignal: options.abortSignal, timeoutInMs: timeoutInMs },\n );\n };\n\n const config: RetryConfig<AwaitableSender> = {\n operation: createLinkPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.senderLink,\n abortSignal: options.abortSignal,\n retryOptions: retryOptions,\n };\n\n try {\n return await retry<AwaitableSender>(config);\n } catch (err: any) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while creating: %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Initializes the sender session on the connection.\n * Should only be called from _createLinkIfNotOpen\n */\n private async _init(\n options: AwaitableSenderOptions & {\n abortSignal: AbortSignalLike | undefined;\n timeoutInMs: number;\n },\n ): Promise<AwaitableSender> {\n const createSender = async () => {\n this.logger.verbose(\"trying to be created...\");\n\n const sender = await this._context.connection.createAwaitableSender(options);\n this._sender = sender;\n this._populateLocalPublishingProperties(this._sender);\n this.isConnecting = false;\n this.logger.verbose(\"created with options: %O\", options);\n\n // It is possible for someone to close the sender and then start it again.\n // Thus make sure that the sender is present in the client cache.\n if (!this._context.senders[this.name]) this._context.senders[this.name] = this;\n };\n try {\n if (!this.isOpen() || !this._sender) {\n await this._context.readyToOpenLink();\n this.authLoop = await withAuth(\n createSender,\n this._context,\n this.audience,\n options.timeoutInMs,\n this.logger,\n { abortSignal: options.abortSignal },\n );\n // it is guaranteed to be defined at this point, otherwise, an error would\n // have been thrown.\n return this._sender!;\n } else {\n this.logger.verbose(\"is open -> %s. Hence not reconnecting.\", this.isOpen());\n return this._sender;\n }\n } catch (err) {\n const translatedError = translate(err);\n this.logger.warning(\n \"an error occurred while being created: %s\",\n `${translatedError?.name}: ${translatedError?.message}`,\n );\n logErrorStackTrace(translatedError);\n throw translatedError;\n }\n }\n\n /**\n * Creates a new sender to the given event hub, and optionally to a given partition if it is\n * not present in the context or returns the one present in the context.\n * @hidden\n * @param options - Options used to configure the EventHubSender.\n */\n static create(\n context: ConnectionContext,\n senderId: string,\n options: EventHubSenderOptions,\n ): EventHubSender {\n const ehSender: EventHubSender = new EventHubSender(context, senderId, options);\n if (!context.senders[ehSender.name]) {\n context.senders[ehSender.name] = ehSender;\n }\n return context.senders[ehSender.name];\n }\n}\n\n/**\n * Generates the link properties for an indemopotent sender given\n * based on the user-provided and locally-cached publishing options.\n *\n * Note: The set of idempotent properties a user specifies at EventHubProducerClient instantiation-time\n * is slightly different than what the service returns and the EventHubSender keeps track of locally.\n *\n * The difference is that the user specifies the `startingSequenceNumber`, whereas the local options\n * (those returned by getPartitionPublishingProperties) specifies `lastPublishedSequenceNumber`.\n *\n * These _can_ be the same, but the user is technically free to set any `startingSequenceNumber` they want.\n * @internal\n */\nexport function generateIdempotentLinkProperties(\n userProvidedPublishingOptions: PartitionPublishingOptions | undefined,\n localPublishingOptions: PartitionPublishingProperties | undefined,\n): IdempotentLinkProperties | Record<string, never> {\n let ownerLevel: number | undefined;\n let producerGroupId: number | undefined;\n let sequenceNumber: number | undefined;\n\n // Prefer local publishing options since this is the up-to-date state of the sender.\n // Only use user-provided publishing options the first time we create the link.\n if (localPublishingOptions) {\n ownerLevel = localPublishingOptions.ownerLevel;\n producerGroupId = localPublishingOptions.producerGroupId;\n sequenceNumber = localPublishingOptions.lastPublishedSequenceNumber;\n } else if (userProvidedPublishingOptions) {\n ownerLevel = userProvidedPublishingOptions.ownerLevel;\n producerGroupId = userProvidedPublishingOptions.producerGroupId;\n sequenceNumber = userProvidedPublishingOptions.startingSequenceNumber;\n } else {\n // If we don't have any properties at all, send an empty object.\n // This will cause the service to generate a new producer-id for our client.\n return {};\n }\n\n // The service requires that if ANY_ of these properties are defined,\n // they _ALL_ have to be defined.\n // If we don't have one of the required values, use `null` and the\n // service will provide it.\n const idempotentLinkProperties: IdempotentLinkProperties = {\n [idempotentProducerAmqpPropertyNames.epoch]: isDefined(ownerLevel)\n ? types.wrap_short(ownerLevel)\n : null,\n [idempotentProducerAmqpPropertyNames.producerId]: isDefined(producerGroupId)\n ? types.wrap_long(producerGroupId)\n : null,\n [idempotentProducerAmqpPropertyNames.producerSequenceNumber]: isDefined(sequenceNumber)\n ? types.wrap_int(sequenceNumber)\n : null,\n };\n\n return idempotentLinkProperties;\n}\n\n/**\n * Encodes a list or batch of events into a single binary message that can be sent to the service.\n *\n * Prior to encoding, any special properties not specified by the user, such as tracing or idempotent\n * properties, are assigned to the list or batch of events as needed.\n *\n * @internal\n * @param events - Events to transform for sending to the service.\n * @param publishingProps - Describes the current publishing state for the partition.\n * @param options - Options used to configure this function.\n */\nexport function transformEventsForSend(\n events: EventData[] | EventDataBatch,\n publishingProps: PartitionPublishingProperties,\n options: SendOptions & {\n /**\n * A list containing the `Diagnostic-Id` tracing property that is associated with each EventData.\n * The index of tracingProperties corresponds to the same index in `events` when `events` is EventData[].\n */\n tracingProperties?: Array<EventData[\"properties\"]>;\n } = {},\n): Buffer {\n if (isEventDataBatch(events)) {\n return (events as EventDataBatchImpl)._generateMessage(publishingProps);\n } else {\n const eventCount = events.length;\n // convert events to rhea messages\n const rheaMessages: RheaMessage[] = [];\n const tracingProperties = options.tracingProperties ?? [];\n for (let i = 0; i < eventCount; i++) {\n const originalEvent = events[i];\n const tracingProperty = tracingProperties[i];\n // Create a copy of the user's event so we can add the tracing property.\n const event: EventData = {\n ...originalEvent,\n properties: { ...originalEvent.properties, ...tracingProperty },\n };\n const rheaMessage = toRheaMessage(event, options.partitionKey);\n\n // populate idempotent message annotations\n const { lastPublishedSequenceNumber = 0 } = publishingProps;\n const startingSequenceNumber = lastPublishedSequenceNumber + 1;\n const pendingPublishSequenceNumber = startingSequenceNumber + i;\n populateIdempotentMessageAnnotations(rheaMessage, {\n ...publishingProps,\n publishSequenceNumber: pendingPublishSequenceNumber,\n });\n\n if (publishingProps.isIdempotentPublishingEnabled) {\n // Set pending seq number on user's event.\n (originalEvent as EventDataInternal)[PENDING_PUBLISH_SEQ_NUM_SYMBOL] =\n pendingPublishSequenceNumber;\n }\n\n rheaMessages.push(rheaMessage);\n }\n\n // Encode every amqp message and then convert every encoded message to amqp data section\n const batchMessage: RheaMessage = {\n body: message.data_sections(rheaMessages.map(message.encode)),\n };\n\n // Set message_annotations of the first message as\n // that of the envelope (batch message).\n if (rheaMessages[0].message_annotations) {\n batchMessage.message_annotations = { ...rheaMessages[0].message_annotations };\n }\n\n // Finally encode the envelope (batch message).\n return message.encode(batchMessage);\n }\n}\n\n/**\n * Commits the pending publish sequence number events.\n * EventDataBatch exposes this as `startingPublishSequenceNumber`,\n * EventData not in a batch exposes this as `publishedSequenceNumber`.\n */\nfunction commitIdempotentSequenceNumbers(\n events: Omit<EventDataInternal, \"getRawAmqpMessage\">[] | EventDataBatch,\n): void {\n if (isEventDataBatch(events)) {\n (events as EventDataBatchImpl)._commitPublish();\n } else {\n // For each event, set the `publishedSequenceNumber` equal to the sequence number\n // we set when we attempted to send the events to the service.\n for (const event of events) {\n event._publishedSequenceNumber = event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n delete event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n }\n }\n}\n\n/**\n * Rolls back any pending publish sequence number in the events.\n */\nfunction rollbackIdempotentSequenceNumbers(\n events: Omit<EventDataInternal, \"getRawAmqpMessage\">[] | EventDataBatch,\n): void {\n if (isEventDataBatch(events)) {\n /* No action required. */\n } else {\n for (const event of events) {\n delete event[PENDING_PUBLISH_SEQ_NUM_SYMBOL];\n }\n }\n}\n"]}
|
|
@@ -10,7 +10,7 @@ import { getRetryAttemptTimeoutInMs } from "./util/retries.js";
|
|
|
10
10
|
import { createAbortablePromise } from "@azure/core-util";
|
|
11
11
|
import { getRandomName } from "./util/utils.js";
|
|
12
12
|
import { withAuth } from "./withAuth.js";
|
|
13
|
-
import { receiverIdPropertyName } from "./util/constants.js";
|
|
13
|
+
import { geoReplication, receiverIdPropertyName } from "./util/constants.js";
|
|
14
14
|
const abortLogMessage = "operation has been cancelled by the user";
|
|
15
15
|
/** The time to wait in ms before attempting to read from the queue */
|
|
16
16
|
const qReadIntervalInMs = 20;
|
|
@@ -304,7 +304,7 @@ function createRheaOptions(consumerId, name, address, obj, state, queue, eventPo
|
|
|
304
304
|
if (typeof ownerLevel === "number") {
|
|
305
305
|
rheaOptions.properties[Constants.attachEpoch] = types.wrap_long(ownerLevel);
|
|
306
306
|
}
|
|
307
|
-
rheaOptions.desired_capabilities = [
|
|
307
|
+
rheaOptions.desired_capabilities = [geoReplication];
|
|
308
308
|
if (options.trackLastEnqueuedEventProperties) {
|
|
309
309
|
rheaOptions.desired_capabilities.push(Constants.enableReceiverRuntimeMetricName);
|
|
310
310
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partitionReceiver.js","sourceRoot":"","sources":["../../src/partitionReceiver.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,SAAS,EAET,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,SAAS,GAEV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAKL,KAAK,GACN,MAAM,cAAc,CAAC;AACtB,OAAO,EAAwC,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAiB,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,MAAM,EACN,MAAM,IAAI,WAAW,EAErB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAQ7D,MAAM,eAAe,GAAG,0CAA0C,CAAC;AACnE,sEAAsE;AACtE,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAyD7B,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAC5B,GAAsB,EACtB,aAAqB,EACrB,UAAkB,EAClB,WAAmB,EACnB,aAA4B,EAC5B,UAAoC,EAAE;IAEtC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,WAAW,EA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UAAU,CAAC,cAAc,iCAC3C,WAAW,KACd,WAAW,IACX,CAAC;IACH,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC;IAC3B,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC1C,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;AAC5B,CAAC;AAED,SAAS,UAAU,CAAC,QAA0B,EAAE,YAAoB;IAClE,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n Constants,\n MessagingError,\n RetryOperationType,\n StandardAbortMessage,\n retry,\n translate,\n RetryConfig,\n} from \"@azure/core-amqp\";\nimport {\n EventContext,\n Receiver as Link,\n ReceiverOptions as RheaReceiverOptions,\n Source,\n types,\n} from \"rhea-promise\";\nimport { EventDataInternal, ReceivedEventData, fromRheaMessage } from \"./eventData.js\";\nimport { EventPosition, getEventPositionFilter } from \"./eventPosition.js\";\nimport {\n createSimpleLogger,\n logErrorStackTrace,\n logObj,\n logger as azureLogger,\n SimpleLogger,\n createReceiverLogPrefix,\n} from \"./logger.js\";\nimport { ConnectionContext } from \"./connectionContext.js\";\nimport { PartitionReceiverOptions } from \"./models/private.js\";\nimport { getRetryAttemptTimeoutInMs } from \"./util/retries.js\";\nimport { createAbortablePromise } from \"@azure/core-util\";\nimport { TimerLoop } from \"./util/timerLoop.js\";\nimport { getRandomName } from \"./util/utils.js\";\nimport { withAuth } from \"./withAuth.js\";\nimport { receiverIdPropertyName } from \"./util/constants.js\";\n\ntype Writable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n/** @internal */\nexport type WritableReceiver = Writable<PartitionReceiver>;\n\nconst abortLogMessage = \"operation has been cancelled by the user\";\n/** The time to wait in ms before attempting to read from the queue */\nconst qReadIntervalInMs = 20;\n\n/**\n * A set of information about the last enqueued event of a partition, as observed by the consumer as\n * events are received from the Event Hubs service\n */\nexport interface LastEnqueuedEventProperties {\n /**\n * The sequence number of the event that was last enqueued into the Event Hub partition from which\n * this event was received.\n */\n sequenceNumber?: number;\n /**\n * The date and time, in UTC, that the last event was enqueued into the Event Hub partition from\n * which this event was received.\n */\n enqueuedOn?: Date;\n /**\n * The offset of the event that was last enqueued into the Event Hub partition from which\n * this event was received.\n */\n offset?: string;\n /**\n * The date and time, in UTC, that the last event was retrieved from the Event Hub partition.\n */\n retrievedOn?: Date;\n}\n\n/** @internal */\nexport interface PartitionReceiver {\n readonly checkpoint: number;\n readonly lastEnqueuedEventProperties: LastEnqueuedEventProperties;\n readonly isClosed: boolean;\n readonly close: () => Promise<void>;\n readonly abort: () => Promise<void>;\n readonly isOpen: () => boolean;\n readonly receiveBatch: (\n maxMessageCount: number,\n maxWaitTimeInSeconds?: number,\n abortSignal?: AbortSignalLike,\n ) => Promise<ReceivedEventData[]>;\n /** Needed for tests only */\n readonly _onError?: (error: MessagingError | Error) => void;\n readonly connect: (options: ConnectOptions) => Promise<void>;\n}\n\ninterface ConnectOptions {\n abortSignal: AbortSignalLike | undefined;\n timeoutInMs: number;\n}\n\ninterface ReceiverState {\n link?: Link;\n authLoop?: TimerLoop;\n isConnecting: boolean;\n}\n\n/** @internal */\nexport function createReceiver(\n ctx: ConnectionContext,\n consumerGroup: string,\n consumerId: string,\n partitionId: string,\n eventPosition: EventPosition,\n options: PartitionReceiverOptions = {},\n): PartitionReceiver {\n const address = ctx.config.getReceiverAddress(partitionId, consumerGroup);\n const name = getRandomName(address);\n const audience = ctx.config.getReceiverAudience(partitionId, consumerGroup);\n const logPrefix = createReceiverLogPrefix(consumerId, ctx.connectionId, partitionId);\n const logger = createSimpleLogger(azureLogger, logPrefix);\n const queue: ReceivedEventData[] = [];\n const state: ReceiverState = {\n isConnecting: false,\n };\n\n const obj: WritableReceiver = {\n _onError: undefined,\n checkpoint: -1,\n lastEnqueuedEventProperties: {},\n isClosed: false,\n close: async () => {\n clearHandlers(obj);\n delete ctx.receivers[name];\n logger.verbose(\"deleted the receiver from the client cache\");\n state.authLoop?.stop();\n return state.link\n ?.close()\n .catch((err) => {\n logger.warning(`an error occurred while closing: ${err?.name}: ${err?.message}`);\n logErrorStackTrace(err);\n throw err;\n })\n .finally(() => {\n obj.isClosed = true;\n logger.verbose(\"is closed\");\n state.link = undefined;\n state.authLoop = undefined;\n });\n },\n abort: () => {\n obj._onError?.(new AbortError(StandardAbortMessage));\n logger.info(abortLogMessage);\n return obj.close();\n },\n isOpen: () => {\n const isOpen = !!state.link?.isOpen();\n logger.verbose(`is open? -> ${isOpen}`);\n return isOpen;\n },\n async connect({ abortSignal, timeoutInMs }: ConnectOptions): Promise<void> {\n if (state.isConnecting || obj.isOpen()) {\n return;\n }\n state.isConnecting = true;\n logger.verbose(\"is trying to connect\");\n try {\n await ctx.readyToOpenLink({ abortSignal });\n state.authLoop = await withAuth(\n () =>\n setupLink(\n consumerId,\n ctx,\n name,\n address,\n obj,\n state,\n queue,\n eventPosition,\n logger,\n options,\n abortSignal,\n ),\n ctx,\n audience,\n timeoutInMs,\n logger,\n {\n abortSignal,\n },\n );\n } catch (err) {\n state.isConnecting = false;\n const error = translate(err);\n logger.error(\n `an error occurred while creating the receiver: ${error?.name}: ${error?.message}`,\n );\n logErrorStackTrace(err);\n throw error;\n }\n },\n receiveBatch: (\n maxMessageCount: number,\n maxWaitTimeInSeconds: number = 60,\n abortSignal?: AbortSignalLike,\n ) => {\n const prefetchCount = options.prefetchCount ?? maxMessageCount * 3;\n const cleanupBeforeAbort = (): Promise<void> => {\n logger.info(abortLogMessage);\n return obj.close();\n };\n const retrieveEvents = (): Promise<ReceivedEventData[]> => {\n const eventsToRetrieveCount = Math.max(maxMessageCount - queue.length, 0);\n logger.verbose(\n `already has ${queue.length} events and wants to receive ${eventsToRetrieveCount} more events`,\n );\n if (abortSignal?.aborted) {\n cleanupBeforeAbort();\n return Promise.reject(new AbortError(StandardAbortMessage));\n }\n return obj.isClosed || ctx.wasConnectionCloseCalled || eventsToRetrieveCount === 0\n ? Promise.resolve(queue.splice(0, maxMessageCount))\n : new Promise<void>((resolve, reject) => {\n obj._onError = reject;\n obj // eslint-disable-line promise/catch-or-return\n .connect({\n abortSignal,\n timeoutInMs: getRetryAttemptTimeoutInMs(options.retryOptions),\n })\n .then(() => {\n addCredits(state.link, Math.max(prefetchCount, maxMessageCount) - queue.length);\n logger.verbose(`setting the max wait time to ${maxWaitTimeInSeconds} seconds`);\n return waitForEvents(\n maxMessageCount,\n maxWaitTimeInSeconds * 1000,\n qReadIntervalInMs,\n queue,\n {\n abortSignal,\n cleanupBeforeAbort,\n receivedAfterWait: () =>\n logger.info(\n `${Math.min(\n maxMessageCount,\n queue.length,\n )} messages received within ${maxWaitTimeInSeconds} seconds`,\n ),\n receivedAlready: () =>\n logger.info(`${maxMessageCount} messages already received`),\n receivedNone: () =>\n logger.info(\n `no messages received when max wait time in seconds ${maxWaitTimeInSeconds} is over`,\n ),\n },\n );\n })\n .catch(reject)\n .then(resolve);\n })\n .then(() => queue.splice(0, maxMessageCount))\n .finally(() => clearHandlers(obj));\n };\n return retry(\n Object.defineProperties(\n {\n operation: retrieveEvents,\n operationType: RetryOperationType.receiveMessage,\n abortSignal: abortSignal,\n retryOptions: options.retryOptions ?? {},\n },\n {\n connectionId: {\n enumerable: true,\n get: () => ctx.connectionId,\n },\n connectionHost: {\n enumerable: true,\n get: () => ctx.config.host,\n },\n },\n ) as RetryConfig<ReceivedEventData[]>,\n );\n },\n };\n return obj;\n}\n\nfunction delay(\n waitTimeInMs: number,\n options?: {\n abortSignal?: AbortSignalLike;\n cleanupBeforeAbort?: () => void;\n abortErrorMsg?: string;\n },\n): Promise<void> {\n let token: ReturnType<typeof setTimeout>;\n return createAbortablePromise<void>((resolve) => {\n token = setTimeout(resolve, waitTimeInMs);\n }, options).finally(() => clearTimeout(token));\n}\n\n/**\n * @internal\n */\nexport function checkOnInterval(\n waitTimeInMs: number,\n check: () => boolean,\n options?: {\n abortSignal?: AbortSignalLike;\n cleanupBeforeAbort?: () => void;\n abortErrorMsg?: string;\n },\n): Promise<void> {\n let token: ReturnType<typeof setInterval>;\n return createAbortablePromise<void>((resolve) => {\n token = setInterval(() => {\n if (check()) {\n resolve();\n }\n }, waitTimeInMs);\n }, options).finally(() => clearInterval(token));\n}\n\n/**\n * Returns a promise that will resolve when it is time to read from the queue\n * @param maxEventCount - The maximum number of events to receive.\n * @param maxWaitTimeInMs - The maximum time to wait in ms for the queue to contain any events.\n * @param readIntervalWaitTimeInMs - The time interval to wait in ms before checking the queue.\n * @param queue - The queue to read from.\n * @param options - The options bag.\n * @returns a promise that will resolve when it is time to read from the queue\n * @internal\n */\nexport function waitForEvents(\n maxEventCount: number,\n maxWaitTimeInMs: number,\n readIntervalWaitTimeInMs: number,\n queue: unknown[],\n options: {\n abortSignal?: AbortSignalLike;\n cleanupBeforeAbort?: () => void;\n receivedAfterWait?: () => void;\n receivedAlready?: () => void;\n receivedNone?: () => void;\n } = {},\n): Promise<void> {\n const {\n abortSignal: clientAbortSignal,\n cleanupBeforeAbort,\n receivedNone,\n receivedAfterWait,\n receivedAlready,\n } = options;\n\n if (queue.length >= maxEventCount) {\n return Promise.resolve().then(receivedAlready);\n }\n\n const aborter = new AbortController();\n const abortListener = () => {\n aborter.abort();\n };\n clientAbortSignal?.addEventListener(\"abort\", abortListener);\n let cleanupBeforeAbortCalled = false;\n\n const updatedOptions = {\n abortSignal: aborter.signal,\n abortErrorMsg: StandardAbortMessage,\n cleanupBeforeAbort: () => {\n if (clientAbortSignal?.aborted && !cleanupBeforeAbortCalled) {\n cleanupBeforeAbort?.();\n cleanupBeforeAbortCalled = true;\n }\n },\n };\n return Promise.race([\n checkOnInterval(readIntervalWaitTimeInMs, () => queue.length > 0, updatedOptions)\n .then(() => delay(readIntervalWaitTimeInMs, updatedOptions))\n .then(receivedAfterWait),\n delay(maxWaitTimeInMs, updatedOptions).then(receivedNone),\n ]).finally(() => {\n aborter.abort();\n clientAbortSignal?.removeEventListener(\"abort\", abortListener);\n });\n}\n\nfunction convertAMQPMesage(data: EventDataInternal): ReceivedEventData {\n const rawMessage = data.getRawAmqpMessage();\n const receivedEventData: ReceivedEventData = {\n body: data.body,\n properties: data.properties,\n offset: data.offset!,\n sequenceNumber: data.sequenceNumber!,\n enqueuedTimeUtc: data.enqueuedTimeUtc!,\n partitionKey: data.partitionKey!,\n systemProperties: data.systemProperties,\n getRawAmqpMessage() {\n return rawMessage;\n },\n };\n if (data.correlationId != null) {\n receivedEventData.correlationId = data.correlationId;\n }\n if (data.contentType != null) {\n receivedEventData.contentType = data.contentType;\n }\n if (data.messageId != null) {\n receivedEventData.messageId = data.messageId;\n }\n return receivedEventData;\n}\n\nfunction setEventProps(eventProps: LastEnqueuedEventProperties, data: EventDataInternal): void {\n eventProps.sequenceNumber = data.lastSequenceNumber;\n eventProps.enqueuedOn = data.lastEnqueuedTime;\n eventProps.offset = data.lastEnqueuedOffset;\n eventProps.retrievedOn = data.retrievalTime;\n}\n\nfunction clearHandlers(obj: WritableReceiver): void {\n obj._onError = undefined;\n}\n\nfunction onMessage(\n context: EventContext,\n obj: WritableReceiver,\n queue: ReceivedEventData[],\n options: PartitionReceiverOptions,\n): void {\n if (!context.message) {\n return;\n }\n const data = fromRheaMessage(context.message, !!options.skipParsingBodyAsJson);\n const receivedEventData = convertAMQPMesage(data);\n obj.checkpoint = receivedEventData.sequenceNumber;\n if (options.trackLastEnqueuedEventProperties) {\n setEventProps(obj.lastEnqueuedEventProperties, data);\n }\n queue.push(receivedEventData);\n}\n\nfunction onError(\n context: EventContext,\n obj: PartitionReceiver,\n receiver: Link | undefined,\n logger: SimpleLogger,\n): void {\n const rheaReceiver = receiver || context.receiver;\n const amqpError = rheaReceiver?.error;\n logger.verbose(`'receiver_error' event occurred: ${logObj(amqpError)}`);\n if (obj._onError && amqpError) {\n const error = translate(amqpError);\n logErrorStackTrace(error);\n obj._onError(error);\n }\n}\n\nfunction onSessionError(context: EventContext, obj: PartitionReceiver, logger: SimpleLogger): void {\n const sessionError = context.session?.error;\n logger.verbose(`'session_error' event occurred: ${logObj(sessionError)}`);\n if (obj._onError && sessionError) {\n const error = translate(sessionError);\n logErrorStackTrace(error);\n obj._onError(error);\n }\n}\n\nasync function onClose(\n context: EventContext,\n state: ReceiverState,\n logger: SimpleLogger,\n): Promise<void> {\n const rheaReceiver = state.link || context.receiver;\n logger.verbose(\n `'receiver_close' event occurred. Value for isItselfClosed on the receiver is: '${rheaReceiver\n ?.isItselfClosed()\n .toString()}' Value for isConnecting on the session is: '${state.isConnecting}'`,\n );\n if (rheaReceiver && !state.isConnecting) {\n return rheaReceiver.close().catch((err) => {\n logger.verbose(`error when closing after 'receiver_close' event: ${logObj(err)}`);\n });\n }\n}\n\nasync function onSessionClose(\n context: EventContext,\n state: ReceiverState,\n logger: SimpleLogger,\n): Promise<void> {\n const rheaReceiver = state.link || context.receiver;\n logger.verbose(\n `'session_close' event occurred. Value for isSessionItselfClosed on the session is: '${rheaReceiver\n ?.isSessionItselfClosed()\n .toString()}' Value for isConnecting on the session is: '${state.isConnecting}'`,\n );\n if (rheaReceiver && !state.isConnecting) {\n return rheaReceiver.close().catch((err) => {\n logger.verbose(`error when closing after 'session_close' event: ${logObj(err)}`);\n });\n }\n}\n\nfunction createRheaOptions(\n consumerId: string,\n name: string,\n address: string,\n obj: PartitionReceiver,\n state: ReceiverState,\n queue: ReceivedEventData[],\n eventPosition: EventPosition,\n logger: SimpleLogger,\n options: PartitionReceiverOptions,\n): RheaReceiverOptions {\n const rheaOptions: RheaReceiverOptions & { source: Source; properties: Record<string, any> } = {\n name,\n autoaccept: true,\n target: consumerId,\n source: {\n address,\n },\n credit_window: 0,\n properties: {\n [receiverIdPropertyName]: consumerId,\n },\n onClose: (context) => onClose(context, state, logger),\n onSessionClose: (context) => onSessionClose(context, state, logger),\n onError: (context) => onError(context, obj, state.link, logger),\n onMessage: (context) => onMessage(context, obj, queue, options),\n onSessionError: (context) => onSessionError(context, obj, logger),\n };\n const ownerLevel = options.ownerLevel;\n if (typeof ownerLevel === \"number\") {\n rheaOptions.properties[Constants.attachEpoch] = types.wrap_long(ownerLevel);\n }\n rheaOptions.desired_capabilities = [Constants.geoReplication];\n if (options.trackLastEnqueuedEventProperties) {\n rheaOptions.desired_capabilities.push(Constants.enableReceiverRuntimeMetricName);\n }\n const filterClause = getEventPositionFilter(\n obj.checkpoint > -1 ? { sequenceNumber: obj.checkpoint } : eventPosition,\n );\n rheaOptions.source.filter = {\n \"apache.org:selector-filter:string\": types.wrap_described(filterClause, 0x468c00000004),\n };\n return rheaOptions;\n}\n\nasync function setupLink(\n consumerId: string,\n ctx: ConnectionContext,\n name: string,\n address: string,\n obj: PartitionReceiver,\n state: ReceiverState,\n queue: ReceivedEventData[],\n eventPosition: EventPosition,\n logger: SimpleLogger,\n options: PartitionReceiverOptions,\n abortSignal?: AbortSignalLike,\n): Promise<void> {\n const rheaOptions = createRheaOptions(\n consumerId,\n name,\n address,\n obj,\n state,\n queue,\n eventPosition,\n logger,\n options,\n );\n logger.verbose(`trying to be created with options ${logObj(rheaOptions)}`);\n state.link = await ctx.connection.createReceiver({\n ...rheaOptions,\n abortSignal,\n });\n state.isConnecting = false;\n logger.verbose(\"is created successfully\");\n ctx.receivers[name] = obj;\n}\n\nfunction addCredits(receiver: Link | undefined, creditsToAdd: number): void {\n if (creditsToAdd > 0) {\n receiver?.addCredit(creditsToAdd);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"partitionReceiver.js","sourceRoot":"","sources":["../../src/partitionReceiver.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,SAAS,EAET,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,SA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CAAC;IACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError, AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n Constants,\n MessagingError,\n RetryOperationType,\n StandardAbortMessage,\n retry,\n translate,\n RetryConfig,\n} from \"@azure/core-amqp\";\nimport {\n EventContext,\n Receiver as Link,\n ReceiverOptions as RheaReceiverOptions,\n Source,\n types,\n} from \"rhea-promise\";\nimport { EventDataInternal, ReceivedEventData, fromRheaMessage } from \"./eventData.js\";\nimport { EventPosition, getEventPositionFilter } from \"./eventPosition.js\";\nimport {\n createSimpleLogger,\n logErrorStackTrace,\n logObj,\n logger as azureLogger,\n SimpleLogger,\n createReceiverLogPrefix,\n} from \"./logger.js\";\nimport { ConnectionContext } from \"./connectionContext.js\";\nimport { PartitionReceiverOptions } from \"./models/private.js\";\nimport { getRetryAttemptTimeoutInMs } from \"./util/retries.js\";\nimport { createAbortablePromise } from \"@azure/core-util\";\nimport { TimerLoop } from \"./util/timerLoop.js\";\nimport { getRandomName } from \"./util/utils.js\";\nimport { withAuth } from \"./withAuth.js\";\nimport { geoReplication, receiverIdPropertyName } from \"./util/constants.js\";\n\ntype Writable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n/** @internal */\nexport type WritableReceiver = Writable<PartitionReceiver>;\n\nconst abortLogMessage = \"operation has been cancelled by the user\";\n/** The time to wait in ms before attempting to read from the queue */\nconst qReadIntervalInMs = 20;\n\n/**\n * A set of information about the last enqueued event of a partition, as observed by the consumer as\n * events are received from the Event Hubs service\n */\nexport interface LastEnqueuedEventProperties {\n /**\n * The sequence number of the event that was last enqueued into the Event Hub partition from which\n * this event was received.\n */\n sequenceNumber?: number;\n /**\n * The date and time, in UTC, that the last event was enqueued into the Event Hub partition from\n * which this event was received.\n */\n enqueuedOn?: Date;\n /**\n * The offset of the event that was last enqueued into the Event Hub partition from which\n * this event was received.\n */\n offset?: string;\n /**\n * The date and time, in UTC, that the last event was retrieved from the Event Hub partition.\n */\n retrievedOn?: Date;\n}\n\n/** @internal */\nexport interface PartitionReceiver {\n readonly checkpoint: number;\n readonly lastEnqueuedEventProperties: LastEnqueuedEventProperties;\n readonly isClosed: boolean;\n readonly close: () => Promise<void>;\n readonly abort: () => Promise<void>;\n readonly isOpen: () => boolean;\n readonly receiveBatch: (\n maxMessageCount: number,\n maxWaitTimeInSeconds?: number,\n abortSignal?: AbortSignalLike,\n ) => Promise<ReceivedEventData[]>;\n /** Needed for tests only */\n readonly _onError?: (error: MessagingError | Error) => void;\n readonly connect: (options: ConnectOptions) => Promise<void>;\n}\n\ninterface ConnectOptions {\n abortSignal: AbortSignalLike | undefined;\n timeoutInMs: number;\n}\n\ninterface ReceiverState {\n link?: Link;\n authLoop?: TimerLoop;\n isConnecting: boolean;\n}\n\n/** @internal */\nexport function createReceiver(\n ctx: ConnectionContext,\n consumerGroup: string,\n consumerId: string,\n partitionId: string,\n eventPosition: EventPosition,\n options: PartitionReceiverOptions = {},\n): PartitionReceiver {\n const address = ctx.config.getReceiverAddress(partitionId, consumerGroup);\n const name = getRandomName(address);\n const audience = ctx.config.getReceiverAudience(partitionId, consumerGroup);\n const logPrefix = createReceiverLogPrefix(consumerId, ctx.connectionId, partitionId);\n const logger = createSimpleLogger(azureLogger, logPrefix);\n const queue: ReceivedEventData[] = [];\n const state: ReceiverState = {\n isConnecting: false,\n };\n\n const obj: WritableReceiver = {\n _onError: undefined,\n checkpoint: -1,\n lastEnqueuedEventProperties: {},\n isClosed: false,\n close: async () => {\n clearHandlers(obj);\n delete ctx.receivers[name];\n logger.verbose(\"deleted the receiver from the client cache\");\n state.authLoop?.stop();\n return state.link\n ?.close()\n .catch((err) => {\n logger.warning(`an error occurred while closing: ${err?.name}: ${err?.message}`);\n logErrorStackTrace(err);\n throw err;\n })\n .finally(() => {\n obj.isClosed = true;\n logger.verbose(\"is closed\");\n state.link = undefined;\n state.authLoop = undefined;\n });\n },\n abort: () => {\n obj._onError?.(new AbortError(StandardAbortMessage));\n logger.info(abortLogMessage);\n return obj.close();\n },\n isOpen: () => {\n const isOpen = !!state.link?.isOpen();\n logger.verbose(`is open? -> ${isOpen}`);\n return isOpen;\n },\n async connect({ abortSignal, timeoutInMs }: ConnectOptions): Promise<void> {\n if (state.isConnecting || obj.isOpen()) {\n return;\n }\n state.isConnecting = true;\n logger.verbose(\"is trying to connect\");\n try {\n await ctx.readyToOpenLink({ abortSignal });\n state.authLoop = await withAuth(\n () =>\n setupLink(\n consumerId,\n ctx,\n name,\n address,\n obj,\n state,\n queue,\n eventPosition,\n logger,\n options,\n abortSignal,\n ),\n ctx,\n audience,\n timeoutInMs,\n logger,\n {\n abortSignal,\n },\n );\n } catch (err) {\n state.isConnecting = false;\n const error = translate(err);\n logger.error(\n `an error occurred while creating the receiver: ${error?.name}: ${error?.message}`,\n );\n logErrorStackTrace(err);\n throw error;\n }\n },\n receiveBatch: (\n maxMessageCount: number,\n maxWaitTimeInSeconds: number = 60,\n abortSignal?: AbortSignalLike,\n ) => {\n const prefetchCount = options.prefetchCount ?? maxMessageCount * 3;\n const cleanupBeforeAbort = (): Promise<void> => {\n logger.info(abortLogMessage);\n return obj.close();\n };\n const retrieveEvents = (): Promise<ReceivedEventData[]> => {\n const eventsToRetrieveCount = Math.max(maxMessageCount - queue.length, 0);\n logger.verbose(\n `already has ${queue.length} events and wants to receive ${eventsToRetrieveCount} more events`,\n );\n if (abortSignal?.aborted) {\n cleanupBeforeAbort();\n return Promise.reject(new AbortError(StandardAbortMessage));\n }\n return obj.isClosed || ctx.wasConnectionCloseCalled || eventsToRetrieveCount === 0\n ? Promise.resolve(queue.splice(0, maxMessageCount))\n : new Promise<void>((resolve, reject) => {\n obj._onError = reject;\n obj // eslint-disable-line promise/catch-or-return\n .connect({\n abortSignal,\n timeoutInMs: getRetryAttemptTimeoutInMs(options.retryOptions),\n })\n .then(() => {\n addCredits(state.link, Math.max(prefetchCount, maxMessageCount) - queue.length);\n logger.verbose(`setting the max wait time to ${maxWaitTimeInSeconds} seconds`);\n return waitForEvents(\n maxMessageCount,\n maxWaitTimeInSeconds * 1000,\n qReadIntervalInMs,\n queue,\n {\n abortSignal,\n cleanupBeforeAbort,\n receivedAfterWait: () =>\n logger.info(\n `${Math.min(\n maxMessageCount,\n queue.length,\n )} messages received within ${maxWaitTimeInSeconds} seconds`,\n ),\n receivedAlready: () =>\n logger.info(`${maxMessageCount} messages already received`),\n receivedNone: () =>\n logger.info(\n `no messages received when max wait time in seconds ${maxWaitTimeInSeconds} is over`,\n ),\n },\n );\n })\n .catch(reject)\n .then(resolve);\n })\n .then(() => queue.splice(0, maxMessageCount))\n .finally(() => clearHandlers(obj));\n };\n return retry(\n Object.defineProperties(\n {\n operation: retrieveEvents,\n operationType: RetryOperationType.receiveMessage,\n abortSignal: abortSignal,\n retryOptions: options.retryOptions ?? {},\n },\n {\n connectionId: {\n enumerable: true,\n get: () => ctx.connectionId,\n },\n connectionHost: {\n enumerable: true,\n get: () => ctx.config.host,\n },\n },\n ) as RetryConfig<ReceivedEventData[]>,\n );\n },\n };\n return obj;\n}\n\nfunction delay(\n waitTimeInMs: number,\n options?: {\n abortSignal?: AbortSignalLike;\n cleanupBeforeAbort?: () => void;\n abortErrorMsg?: string;\n },\n): Promise<void> {\n let token: ReturnType<typeof setTimeout>;\n return createAbortablePromise<void>((resolve) => {\n token = setTimeout(resolve, waitTimeInMs);\n }, options).finally(() => clearTimeout(token));\n}\n\n/**\n * @internal\n */\nexport function checkOnInterval(\n waitTimeInMs: number,\n check: () => boolean,\n options?: {\n abortSignal?: AbortSignalLike;\n cleanupBeforeAbort?: () => void;\n abortErrorMsg?: string;\n },\n): Promise<void> {\n let token: ReturnType<typeof setInterval>;\n return createAbortablePromise<void>((resolve) => {\n token = setInterval(() => {\n if (check()) {\n resolve();\n }\n }, waitTimeInMs);\n }, options).finally(() => clearInterval(token));\n}\n\n/**\n * Returns a promise that will resolve when it is time to read from the queue\n * @param maxEventCount - The maximum number of events to receive.\n * @param maxWaitTimeInMs - The maximum time to wait in ms for the queue to contain any events.\n * @param readIntervalWaitTimeInMs - The time interval to wait in ms before checking the queue.\n * @param queue - The queue to read from.\n * @param options - The options bag.\n * @returns a promise that will resolve when it is time to read from the queue\n * @internal\n */\nexport function waitForEvents(\n maxEventCount: number,\n maxWaitTimeInMs: number,\n readIntervalWaitTimeInMs: number,\n queue: unknown[],\n options: {\n abortSignal?: AbortSignalLike;\n cleanupBeforeAbort?: () => void;\n receivedAfterWait?: () => void;\n receivedAlready?: () => void;\n receivedNone?: () => void;\n } = {},\n): Promise<void> {\n const {\n abortSignal: clientAbortSignal,\n cleanupBeforeAbort,\n receivedNone,\n receivedAfterWait,\n receivedAlready,\n } = options;\n\n if (queue.length >= maxEventCount) {\n return Promise.resolve().then(receivedAlready);\n }\n\n const aborter = new AbortController();\n const abortListener = () => {\n aborter.abort();\n };\n clientAbortSignal?.addEventListener(\"abort\", abortListener);\n let cleanupBeforeAbortCalled = false;\n\n const updatedOptions = {\n abortSignal: aborter.signal,\n abortErrorMsg: StandardAbortMessage,\n cleanupBeforeAbort: () => {\n if (clientAbortSignal?.aborted && !cleanupBeforeAbortCalled) {\n cleanupBeforeAbort?.();\n cleanupBeforeAbortCalled = true;\n }\n },\n };\n return Promise.race([\n checkOnInterval(readIntervalWaitTimeInMs, () => queue.length > 0, updatedOptions)\n .then(() => delay(readIntervalWaitTimeInMs, updatedOptions))\n .then(receivedAfterWait),\n delay(maxWaitTimeInMs, updatedOptions).then(receivedNone),\n ]).finally(() => {\n aborter.abort();\n clientAbortSignal?.removeEventListener(\"abort\", abortListener);\n });\n}\n\nfunction convertAMQPMesage(data: EventDataInternal): ReceivedEventData {\n const rawMessage = data.getRawAmqpMessage();\n const receivedEventData: ReceivedEventData = {\n body: data.body,\n properties: data.properties,\n offset: data.offset!,\n sequenceNumber: data.sequenceNumber!,\n enqueuedTimeUtc: data.enqueuedTimeUtc!,\n partitionKey: data.partitionKey!,\n systemProperties: data.systemProperties,\n getRawAmqpMessage() {\n return rawMessage;\n },\n };\n if (data.correlationId != null) {\n receivedEventData.correlationId = data.correlationId;\n }\n if (data.contentType != null) {\n receivedEventData.contentType = data.contentType;\n }\n if (data.messageId != null) {\n receivedEventData.messageId = data.messageId;\n }\n return receivedEventData;\n}\n\nfunction setEventProps(eventProps: LastEnqueuedEventProperties, data: EventDataInternal): void {\n eventProps.sequenceNumber = data.lastSequenceNumber;\n eventProps.enqueuedOn = data.lastEnqueuedTime;\n eventProps.offset = data.lastEnqueuedOffset;\n eventProps.retrievedOn = data.retrievalTime;\n}\n\nfunction clearHandlers(obj: WritableReceiver): void {\n obj._onError = undefined;\n}\n\nfunction onMessage(\n context: EventContext,\n obj: WritableReceiver,\n queue: ReceivedEventData[],\n options: PartitionReceiverOptions,\n): void {\n if (!context.message) {\n return;\n }\n const data = fromRheaMessage(context.message, !!options.skipParsingBodyAsJson);\n const receivedEventData = convertAMQPMesage(data);\n obj.checkpoint = receivedEventData.sequenceNumber;\n if (options.trackLastEnqueuedEventProperties) {\n setEventProps(obj.lastEnqueuedEventProperties, data);\n }\n queue.push(receivedEventData);\n}\n\nfunction onError(\n context: EventContext,\n obj: PartitionReceiver,\n receiver: Link | undefined,\n logger: SimpleLogger,\n): void {\n const rheaReceiver = receiver || context.receiver;\n const amqpError = rheaReceiver?.error;\n logger.verbose(`'receiver_error' event occurred: ${logObj(amqpError)}`);\n if (obj._onError && amqpError) {\n const error = translate(amqpError);\n logErrorStackTrace(error);\n obj._onError(error);\n }\n}\n\nfunction onSessionError(context: EventContext, obj: PartitionReceiver, logger: SimpleLogger): void {\n const sessionError = context.session?.error;\n logger.verbose(`'session_error' event occurred: ${logObj(sessionError)}`);\n if (obj._onError && sessionError) {\n const error = translate(sessionError);\n logErrorStackTrace(error);\n obj._onError(error);\n }\n}\n\nasync function onClose(\n context: EventContext,\n state: ReceiverState,\n logger: SimpleLogger,\n): Promise<void> {\n const rheaReceiver = state.link || context.receiver;\n logger.verbose(\n `'receiver_close' event occurred. Value for isItselfClosed on the receiver is: '${rheaReceiver\n ?.isItselfClosed()\n .toString()}' Value for isConnecting on the session is: '${state.isConnecting}'`,\n );\n if (rheaReceiver && !state.isConnecting) {\n return rheaReceiver.close().catch((err) => {\n logger.verbose(`error when closing after 'receiver_close' event: ${logObj(err)}`);\n });\n }\n}\n\nasync function onSessionClose(\n context: EventContext,\n state: ReceiverState,\n logger: SimpleLogger,\n): Promise<void> {\n const rheaReceiver = state.link || context.receiver;\n logger.verbose(\n `'session_close' event occurred. Value for isSessionItselfClosed on the session is: '${rheaReceiver\n ?.isSessionItselfClosed()\n .toString()}' Value for isConnecting on the session is: '${state.isConnecting}'`,\n );\n if (rheaReceiver && !state.isConnecting) {\n return rheaReceiver.close().catch((err) => {\n logger.verbose(`error when closing after 'session_close' event: ${logObj(err)}`);\n });\n }\n}\n\nfunction createRheaOptions(\n consumerId: string,\n name: string,\n address: string,\n obj: PartitionReceiver,\n state: ReceiverState,\n queue: ReceivedEventData[],\n eventPosition: EventPosition,\n logger: SimpleLogger,\n options: PartitionReceiverOptions,\n): RheaReceiverOptions {\n const rheaOptions: RheaReceiverOptions & { source: Source; properties: Record<string, any> } = {\n name,\n autoaccept: true,\n target: consumerId,\n source: {\n address,\n },\n credit_window: 0,\n properties: {\n [receiverIdPropertyName]: consumerId,\n },\n onClose: (context) => onClose(context, state, logger),\n onSessionClose: (context) => onSessionClose(context, state, logger),\n onError: (context) => onError(context, obj, state.link, logger),\n onMessage: (context) => onMessage(context, obj, queue, options),\n onSessionError: (context) => onSessionError(context, obj, logger),\n };\n const ownerLevel = options.ownerLevel;\n if (typeof ownerLevel === \"number\") {\n rheaOptions.properties[Constants.attachEpoch] = types.wrap_long(ownerLevel);\n }\n rheaOptions.desired_capabilities = [geoReplication];\n if (options.trackLastEnqueuedEventProperties) {\n rheaOptions.desired_capabilities.push(Constants.enableReceiverRuntimeMetricName);\n }\n const filterClause = getEventPositionFilter(\n obj.checkpoint > -1 ? { sequenceNumber: obj.checkpoint } : eventPosition,\n );\n rheaOptions.source.filter = {\n \"apache.org:selector-filter:string\": types.wrap_described(filterClause, 0x468c00000004),\n };\n return rheaOptions;\n}\n\nasync function setupLink(\n consumerId: string,\n ctx: ConnectionContext,\n name: string,\n address: string,\n obj: PartitionReceiver,\n state: ReceiverState,\n queue: ReceivedEventData[],\n eventPosition: EventPosition,\n logger: SimpleLogger,\n options: PartitionReceiverOptions,\n abortSignal?: AbortSignalLike,\n): Promise<void> {\n const rheaOptions = createRheaOptions(\n consumerId,\n name,\n address,\n obj,\n state,\n queue,\n eventPosition,\n logger,\n options,\n );\n logger.verbose(`trying to be created with options ${logObj(rheaOptions)}`);\n state.link = await ctx.connection.createReceiver({\n ...rheaOptions,\n abortSignal,\n });\n state.isConnecting = false;\n logger.verbose(\"is created successfully\");\n ctx.receivers[name] = obj;\n}\n\nfunction addCredits(receiver: Link | undefined, creditsToAdd: number): void {\n if (creditsToAdd > 0) {\n receiver?.addCredit(creditsToAdd);\n }\n}\n"]}
|
|
@@ -16,6 +16,8 @@ export declare const idempotentProducerAmqpPropertyNames: {
|
|
|
16
16
|
};
|
|
17
17
|
/** @internal */
|
|
18
18
|
export declare const receiverIdPropertyName = "com.microsoft:receiver-name";
|
|
19
|
+
/** @internal */
|
|
20
|
+
export declare const geoReplication = "com.microsoft:georeplication";
|
|
19
21
|
/**
|
|
20
22
|
* @internal
|
|
21
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/util/constants.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,eAAe;;;CAG3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC;;;;;CAKtC,CAAC;AAEX,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,gCAAgC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,8BAA8B,eAE1C,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/util/constants.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,eAAe;;;CAG3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC;;;;;CAKtC,CAAC;AAEX,gBAAgB;AAChB,eAAO,MAAM,sBAAsB,gCAAgC,CAAC;AAEpE,gBAAgB;AAChB,eAAO,MAAM,cAAc,iCAAiC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,8BAA8B,eAE1C,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const packageJsonInfo = {
|
|
7
7
|
name: "@azure/event-hubs",
|
|
8
|
-
version: "5.13.0
|
|
8
|
+
version: "5.13.0",
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
@@ -18,6 +18,8 @@ export const idempotentProducerAmqpPropertyNames = {
|
|
|
18
18
|
};
|
|
19
19
|
/** @internal */
|
|
20
20
|
export const receiverIdPropertyName = "com.microsoft:receiver-name";
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const geoReplication = "com.microsoft:georeplication";
|
|
21
23
|
/**
|
|
22
24
|
* @internal
|
|
23
25
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/util/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,mBAAmB;IACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/util/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,mBAAmB;IACzB,OAAO,EAAE,QAAQ;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,UAAU,EAAE,mCAAmC;IAC/C,KAAK,EAAE,8BAA8B;IACrC,UAAU,EAAE,2BAA2B;IACvC,sBAAsB,EAAE,wCAAwC;CACxD,CAAC;AAEX,gBAAgB;AAChB,MAAM,CAAC,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAEpE,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,8BAA8B,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,GAAG,CACtD,gDAAgD,CACjD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * @internal\n */\nexport const packageJsonInfo = {\n name: \"@azure/event-hubs\",\n version: \"5.13.0\",\n};\n\n/**\n * @internal\n */\nexport const idempotentProducerAmqpPropertyNames = {\n capability: \"com.microsoft:idempotent-producer\",\n epoch: \"com.microsoft:producer-epoch\",\n producerId: \"com.microsoft:producer-id\",\n producerSequenceNumber: \"com.microsoft:producer-sequence-number\",\n} as const;\n\n/** @internal */\nexport const receiverIdPropertyName = \"com.microsoft:receiver-name\";\n\n/** @internal */\nexport const geoReplication = \"com.microsoft:georeplication\";\n\n/**\n * @internal\n */\nexport const PENDING_PUBLISH_SEQ_NUM_SYMBOL = Symbol.for(\n \"@azure/event-hubs.pendingPublishSequenceNumber\",\n);\n"]}
|
|
@@ -202,10 +202,21 @@ export interface EventData {
|
|
|
202
202
|
[key: string]: any;
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Asserts that the provided data conforms to the `EventData` interface.
|
|
207
|
+
*
|
|
208
|
+
* This function performs runtime checks on the `data` object to ensure it matches the expected
|
|
209
|
+
* structure and types defined in the `EventData` interface. If any of the checks fail, it throws
|
|
210
|
+
* an error with a descriptive message indicating the mismatch.
|
|
211
|
+
*
|
|
212
|
+
* @param data - The data object to validate as `EventData`.
|
|
213
|
+
* @throws \{Error\} Throws an error if the data does not conform to the `EventData` interface.
|
|
214
|
+
*/
|
|
215
|
+
export declare function assertIsEventData(data: any): asserts data is EventData;
|
|
205
216
|
/**
|
|
206
217
|
* The interface that describes the structure of the event received from Event Hub.
|
|
207
218
|
* Use this as a reference when creating the `processEvents` function to process the events
|
|
208
|
-
*
|
|
219
|
+
* received from an Event Hub when using the `EventHubConsumerClient`.
|
|
209
220
|
*/
|
|
210
221
|
export interface ReceivedEventData {
|
|
211
222
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventData.d.ts","sourceRoot":"","sources":["../../src/eventData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAa,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,IAAI,WAAW,EAEvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEL,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"eventData.d.ts","sourceRoot":"","sources":["../../src/eventData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAa,MAAM,kBAAkB,CAAC;AAEnE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,OAAO,IAAI,WAAW,EAEvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEL,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;AAG7B;;;GAGG;AACH,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;OAEG;IACH,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ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,gBAAgB,CAAC,EAAE;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IAEF;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAEzC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAErC;;OAEG;IACH,iBAAiB,IAAI,oBAAoB,CAAC;CAC3C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,oBAAoB,CAK1F;AA2CD;;GAEG;AACH,MAAM,WAAW,8CAA8C;IAC7D,6BAA6B,EAAE,OAAO,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAClD,WAAW,EAAE,WAAW,EACxB,EACE,6BAA6B,EAC7B,UAAU,EACV,eAAe,EACf,qBAAqB,GACtB,EAAE,8CAA8C,GAChD,IAAI,CAqBN"}
|
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.fromRheaMessage = fromRheaMessage;
|
|
6
6
|
exports.toRheaMessage = toRheaMessage;
|
|
7
|
+
exports.assertIsEventData = assertIsEventData;
|
|
7
8
|
exports.isAmqpAnnotatedMessage = isAmqpAnnotatedMessage;
|
|
8
9
|
exports.populateIdempotentMessageAnnotations = populateIdempotentMessageAnnotations;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
9
11
|
const core_amqp_1 = require("@azure/core-amqp");
|
|
10
12
|
const dataTransformer_js_1 = require("./dataTransformer.js");
|
|
11
13
|
const rhea_promise_1 = require("rhea-promise");
|
|
12
14
|
const core_util_1 = require("@azure/core-util");
|
|
13
15
|
const constants_js_1 = require("./util/constants.js");
|
|
16
|
+
const is_buffer_1 = tslib_1.__importDefault(require("is-buffer"));
|
|
14
17
|
const messagePropertiesMap = {
|
|
15
18
|
message_id: "messageId",
|
|
16
19
|
user_id: "userId",
|
|
@@ -120,7 +123,7 @@ function toRheaMessage(data, partitionKey) {
|
|
|
120
123
|
body: dataTransformer_js_1.defaultDataTransformer.encode(data.body, bodyType),
|
|
121
124
|
};
|
|
122
125
|
// As per the AMQP 1.0 spec If the message-annotations or delivery-annotations section is omitted,
|
|
123
|
-
// it is equivalent to a message-annotations section containing
|
|
126
|
+
// it is equivalent to a message-annotations section containing empty map of annotations.
|
|
124
127
|
rheaMessage.message_annotations = {};
|
|
125
128
|
if (data.properties) {
|
|
126
129
|
rheaMessage.application_properties = data.properties;
|
|
@@ -148,6 +151,39 @@ function toRheaMessage(data, partitionKey) {
|
|
|
148
151
|
}
|
|
149
152
|
return rheaMessage;
|
|
150
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Asserts that the provided data conforms to the `EventData` interface.
|
|
156
|
+
*
|
|
157
|
+
* This function performs runtime checks on the `data` object to ensure it matches the expected
|
|
158
|
+
* structure and types defined in the `EventData` interface. If any of the checks fail, it throws
|
|
159
|
+
* an error with a descriptive message indicating the mismatch.
|
|
160
|
+
*
|
|
161
|
+
* @param data - The data object to validate as `EventData`.
|
|
162
|
+
* @throws \{Error\} Throws an error if the data does not conform to the `EventData` interface.
|
|
163
|
+
*/
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
165
|
+
function assertIsEventData(data) {
|
|
166
|
+
if (data.contentType != null && typeof data.contentType !== "string") {
|
|
167
|
+
throw new Error(`Invalid 'contentType': expected 'string' or 'undefined', but received '${typeof data.contentType}'.`);
|
|
168
|
+
}
|
|
169
|
+
if (data.correlationId != null &&
|
|
170
|
+
typeof data.correlationId !== "string" &&
|
|
171
|
+
typeof data.correlationId !== "number" &&
|
|
172
|
+
!(0, is_buffer_1.default)(data.correlationId)) {
|
|
173
|
+
throw new Error(`Invalid 'correlationId': expected 'string', 'number', 'Buffer', or 'undefined', but received '${typeof data.correlationId}'.`);
|
|
174
|
+
}
|
|
175
|
+
if (data.messageId != null &&
|
|
176
|
+
typeof data.messageId !== "string" &&
|
|
177
|
+
typeof data.messageId !== "number" &&
|
|
178
|
+
!(0, is_buffer_1.default)(data.messageId)) {
|
|
179
|
+
throw new Error(`Invalid 'messageId': expected 'string', 'number', 'Buffer', or 'undefined', but received '${typeof data.messageId}'.`);
|
|
180
|
+
}
|
|
181
|
+
if (data.properties !== undefined &&
|
|
182
|
+
(typeof data.properties !== "object" || Array.isArray(data.properties))) {
|
|
183
|
+
const actualType = Array.isArray(data.properties) ? "array" : typeof data.properties;
|
|
184
|
+
throw new Error(`Invalid 'properties': expected an object or 'undefined', but received '${actualType}'.`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
151
187
|
/**
|
|
152
188
|
* @internal
|
|
153
189
|
*/
|