@azure/service-bus 7.10.0-beta.2 → 7.10.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/connectionContext.js +1 -2
- package/dist/browser/connectionContext.js.map +1 -1
- package/dist/browser/constructorHelpers.js +3 -4
- package/dist/browser/constructorHelpers.js.map +1 -1
- package/dist/browser/core/autoLockRenewer.js +9 -5
- package/dist/browser/core/autoLockRenewer.js.map +1 -1
- package/dist/browser/core/batchingReceiver.js +26 -18
- package/dist/browser/core/batchingReceiver.js.map +1 -1
- package/dist/browser/core/linkEntity.js +74 -13
- package/dist/browser/core/linkEntity.js.map +1 -1
- package/dist/browser/core/managementClient.js +48 -48
- package/dist/browser/core/managementClient.js.map +1 -1
- package/dist/browser/core/messageReceiver.js +41 -14
- package/dist/browser/core/messageReceiver.js.map +1 -1
- package/dist/browser/core/messageSender.js +33 -10
- package/dist/browser/core/messageSender.js.map +1 -1
- package/dist/browser/core/receiverHelper.js +3 -2
- package/dist/browser/core/receiverHelper.js.map +1 -1
- package/dist/browser/core/shared.js +11 -4
- package/dist/browser/core/shared.js.map +1 -1
- package/dist/browser/core/streamingReceiver.js +74 -43
- package/dist/browser/core/streamingReceiver.js.map +1 -1
- package/dist/browser/diagnostics/instrumentServiceBusMessage.js +16 -8
- package/dist/browser/diagnostics/instrumentServiceBusMessage.js.map +1 -1
- package/dist/browser/receivers/receiver.js +68 -23
- package/dist/browser/receivers/receiver.js.map +1 -1
- package/dist/browser/receivers/receiverCommon.js +36 -21
- package/dist/browser/receivers/receiverCommon.js.map +1 -1
- package/dist/browser/receivers/sessionReceiver.js +69 -29
- package/dist/browser/receivers/sessionReceiver.js.map +1 -1
- package/dist/browser/sender.js +33 -11
- package/dist/browser/sender.js.map +1 -1
- package/dist/browser/serializers/queueResourceSerializer.js +9 -1
- package/dist/browser/serializers/queueResourceSerializer.js.map +1 -1
- package/dist/browser/serializers/ruleResourceSerializer.js +1 -2
- package/dist/browser/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist/browser/serviceBusAtomManagementClient.js +181 -228
- package/dist/browser/serviceBusAtomManagementClient.js.map +1 -1
- package/dist/browser/serviceBusClient.js +31 -22
- package/dist/browser/serviceBusClient.js.map +1 -1
- package/dist/browser/serviceBusError.js +21 -1
- package/dist/browser/serviceBusError.js.map +1 -1
- package/dist/browser/serviceBusMessage.js +208 -13
- package/dist/browser/serviceBusMessage.js.map +1 -1
- package/dist/browser/serviceBusMessageBatch.js +32 -8
- package/dist/browser/serviceBusMessageBatch.js.map +1 -1
- package/dist/browser/serviceBusRuleManager.js +39 -15
- package/dist/browser/serviceBusRuleManager.js.map +1 -1
- package/dist/browser/session/messageSession.js +130 -25
- package/dist/browser/session/messageSession.js.map +1 -1
- package/dist/browser/util/atomXmlHelper.js +4 -5
- package/dist/browser/util/atomXmlHelper.js.map +1 -1
- package/dist/browser/util/compat/httpHeaders.js +1 -0
- package/dist/browser/util/compat/httpHeaders.js.map +1 -1
- package/dist/browser/util/constants.js +1 -1
- package/dist/browser/util/constants.js.map +1 -1
- package/dist/browser/util/sasServiceClientCredentials.js +8 -0
- package/dist/browser/util/sasServiceClientCredentials.js.map +1 -1
- package/dist/browser/util/semaphore.js +6 -2
- package/dist/browser/util/semaphore.js.map +1 -1
- package/dist/browser/util/utils.js +5 -7
- package/dist/browser/util/utils.js.map +1 -1
- package/dist/commonjs/connectionContext.js +1 -2
- package/dist/commonjs/connectionContext.js.map +1 -1
- package/dist/commonjs/constructorHelpers.js +3 -4
- package/dist/commonjs/constructorHelpers.js.map +1 -1
- package/dist/commonjs/core/autoLockRenewer.js +9 -5
- package/dist/commonjs/core/autoLockRenewer.js.map +1 -1
- package/dist/commonjs/core/batchingReceiver.js +26 -18
- package/dist/commonjs/core/batchingReceiver.js.map +1 -1
- package/dist/commonjs/core/linkEntity.js +74 -13
- package/dist/commonjs/core/linkEntity.js.map +1 -1
- package/dist/commonjs/core/managementClient.js +48 -48
- package/dist/commonjs/core/managementClient.js.map +1 -1
- package/dist/commonjs/core/messageReceiver.js +41 -14
- package/dist/commonjs/core/messageReceiver.js.map +1 -1
- package/dist/commonjs/core/messageSender.js +33 -10
- package/dist/commonjs/core/messageSender.js.map +1 -1
- package/dist/commonjs/core/receiverHelper.js +3 -2
- package/dist/commonjs/core/receiverHelper.js.map +1 -1
- package/dist/commonjs/core/shared.js +11 -4
- package/dist/commonjs/core/shared.js.map +1 -1
- package/dist/commonjs/core/streamingReceiver.js +74 -43
- package/dist/commonjs/core/streamingReceiver.js.map +1 -1
- package/dist/commonjs/diagnostics/instrumentServiceBusMessage.js +16 -8
- package/dist/commonjs/diagnostics/instrumentServiceBusMessage.js.map +1 -1
- package/dist/commonjs/receivers/receiver.js +68 -23
- package/dist/commonjs/receivers/receiver.js.map +1 -1
- package/dist/commonjs/receivers/receiverCommon.js +36 -21
- package/dist/commonjs/receivers/receiverCommon.js.map +1 -1
- package/dist/commonjs/receivers/sessionReceiver.js +69 -29
- package/dist/commonjs/receivers/sessionReceiver.js.map +1 -1
- package/dist/commonjs/sender.js +33 -11
- package/dist/commonjs/sender.js.map +1 -1
- package/dist/commonjs/serializers/queueResourceSerializer.js +9 -1
- package/dist/commonjs/serializers/queueResourceSerializer.js.map +1 -1
- package/dist/commonjs/serializers/ruleResourceSerializer.js +1 -2
- package/dist/commonjs/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist/commonjs/serviceBusAtomManagementClient.js +181 -227
- package/dist/commonjs/serviceBusAtomManagementClient.js.map +1 -1
- package/dist/commonjs/serviceBusClient.js +31 -22
- package/dist/commonjs/serviceBusClient.js.map +1 -1
- package/dist/commonjs/serviceBusError.js +21 -1
- package/dist/commonjs/serviceBusError.js.map +1 -1
- package/dist/commonjs/serviceBusMessage.js +208 -12
- package/dist/commonjs/serviceBusMessage.js.map +1 -1
- package/dist/commonjs/serviceBusMessageBatch.js +32 -8
- package/dist/commonjs/serviceBusMessageBatch.js.map +1 -1
- package/dist/commonjs/serviceBusRuleManager.js +39 -15
- package/dist/commonjs/serviceBusRuleManager.js.map +1 -1
- package/dist/commonjs/session/messageSession.js +130 -25
- package/dist/commonjs/session/messageSession.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/util/atomXmlHelper.js +4 -5
- package/dist/commonjs/util/atomXmlHelper.js.map +1 -1
- package/dist/commonjs/util/compat/httpHeaders.js +1 -0
- package/dist/commonjs/util/compat/httpHeaders.js.map +1 -1
- package/dist/commonjs/util/constants.js +1 -1
- package/dist/commonjs/util/constants.js.map +1 -1
- package/dist/commonjs/util/runtimeInfo.js +2 -2
- package/dist/commonjs/util/runtimeInfo.js.map +1 -1
- package/dist/commonjs/util/sasServiceClientCredentials.js +8 -0
- package/dist/commonjs/util/sasServiceClientCredentials.js.map +1 -1
- package/dist/commonjs/util/semaphore.js +6 -2
- package/dist/commonjs/util/semaphore.js.map +1 -1
- package/dist/commonjs/util/utils.js +5 -7
- package/dist/commonjs/util/utils.js.map +1 -1
- package/dist/esm/connectionContext.js +1 -2
- package/dist/esm/connectionContext.js.map +1 -1
- package/dist/esm/constructorHelpers.js +3 -4
- package/dist/esm/constructorHelpers.js.map +1 -1
- package/dist/esm/core/autoLockRenewer.js +9 -5
- package/dist/esm/core/autoLockRenewer.js.map +1 -1
- package/dist/esm/core/batchingReceiver.js +26 -18
- package/dist/esm/core/batchingReceiver.js.map +1 -1
- package/dist/esm/core/linkEntity.js +74 -13
- package/dist/esm/core/linkEntity.js.map +1 -1
- package/dist/esm/core/managementClient.js +48 -48
- package/dist/esm/core/managementClient.js.map +1 -1
- package/dist/esm/core/messageReceiver.js +41 -14
- package/dist/esm/core/messageReceiver.js.map +1 -1
- package/dist/esm/core/messageSender.js +33 -10
- package/dist/esm/core/messageSender.js.map +1 -1
- package/dist/esm/core/receiverHelper.js +3 -2
- package/dist/esm/core/receiverHelper.js.map +1 -1
- package/dist/esm/core/shared.js +11 -4
- package/dist/esm/core/shared.js.map +1 -1
- package/dist/esm/core/streamingReceiver.js +74 -43
- package/dist/esm/core/streamingReceiver.js.map +1 -1
- package/dist/esm/diagnostics/instrumentServiceBusMessage.js +16 -8
- package/dist/esm/diagnostics/instrumentServiceBusMessage.js.map +1 -1
- package/dist/esm/receivers/receiver.js +68 -23
- package/dist/esm/receivers/receiver.js.map +1 -1
- package/dist/esm/receivers/receiverCommon.js +36 -21
- package/dist/esm/receivers/receiverCommon.js.map +1 -1
- package/dist/esm/receivers/sessionReceiver.js +69 -29
- package/dist/esm/receivers/sessionReceiver.js.map +1 -1
- package/dist/esm/sender.js +33 -11
- package/dist/esm/sender.js.map +1 -1
- package/dist/esm/serializers/queueResourceSerializer.js +9 -1
- package/dist/esm/serializers/queueResourceSerializer.js.map +1 -1
- package/dist/esm/serializers/ruleResourceSerializer.js +1 -2
- package/dist/esm/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist/esm/serviceBusAtomManagementClient.js +181 -228
- package/dist/esm/serviceBusAtomManagementClient.js.map +1 -1
- package/dist/esm/serviceBusClient.js +31 -22
- package/dist/esm/serviceBusClient.js.map +1 -1
- package/dist/esm/serviceBusError.js +21 -1
- package/dist/esm/serviceBusError.js.map +1 -1
- package/dist/esm/serviceBusMessage.js +208 -13
- package/dist/esm/serviceBusMessage.js.map +1 -1
- package/dist/esm/serviceBusMessageBatch.js +32 -8
- package/dist/esm/serviceBusMessageBatch.js.map +1 -1
- package/dist/esm/serviceBusRuleManager.js +39 -15
- package/dist/esm/serviceBusRuleManager.js.map +1 -1
- package/dist/esm/session/messageSession.js +130 -25
- package/dist/esm/session/messageSession.js.map +1 -1
- package/dist/esm/util/atomXmlHelper.js +4 -5
- package/dist/esm/util/atomXmlHelper.js.map +1 -1
- package/dist/esm/util/compat/httpHeaders.js +1 -0
- package/dist/esm/util/compat/httpHeaders.js.map +1 -1
- package/dist/esm/util/constants.js +1 -1
- package/dist/esm/util/constants.js.map +1 -1
- package/dist/esm/util/runtimeInfo.js +1 -1
- package/dist/esm/util/runtimeInfo.js.map +1 -1
- package/dist/esm/util/sasServiceClientCredentials.js +8 -0
- package/dist/esm/util/sasServiceClientCredentials.js.map +1 -1
- package/dist/esm/util/semaphore.js +6 -2
- package/dist/esm/util/semaphore.js.map +1 -1
- package/dist/esm/util/utils.js +5 -7
- package/dist/esm/util/utils.js.map +1 -1
- package/dist/react-native/connectionContext.js +1 -2
- package/dist/react-native/connectionContext.js.map +1 -1
- package/dist/react-native/constructorHelpers.js +3 -4
- package/dist/react-native/constructorHelpers.js.map +1 -1
- package/dist/react-native/core/autoLockRenewer.js +9 -5
- package/dist/react-native/core/autoLockRenewer.js.map +1 -1
- package/dist/react-native/core/batchingReceiver.js +26 -18
- package/dist/react-native/core/batchingReceiver.js.map +1 -1
- package/dist/react-native/core/linkEntity.js +74 -13
- package/dist/react-native/core/linkEntity.js.map +1 -1
- package/dist/react-native/core/managementClient.js +48 -48
- package/dist/react-native/core/managementClient.js.map +1 -1
- package/dist/react-native/core/messageReceiver.js +41 -14
- package/dist/react-native/core/messageReceiver.js.map +1 -1
- package/dist/react-native/core/messageSender.js +33 -10
- package/dist/react-native/core/messageSender.js.map +1 -1
- package/dist/react-native/core/receiverHelper.js +3 -2
- package/dist/react-native/core/receiverHelper.js.map +1 -1
- package/dist/react-native/core/shared.js +11 -4
- package/dist/react-native/core/shared.js.map +1 -1
- package/dist/react-native/core/streamingReceiver.js +74 -43
- package/dist/react-native/core/streamingReceiver.js.map +1 -1
- package/dist/react-native/diagnostics/instrumentServiceBusMessage.js +16 -8
- package/dist/react-native/diagnostics/instrumentServiceBusMessage.js.map +1 -1
- package/dist/react-native/receivers/receiver.js +68 -23
- package/dist/react-native/receivers/receiver.js.map +1 -1
- package/dist/react-native/receivers/receiverCommon.js +36 -21
- package/dist/react-native/receivers/receiverCommon.js.map +1 -1
- package/dist/react-native/receivers/sessionReceiver.js +69 -29
- package/dist/react-native/receivers/sessionReceiver.js.map +1 -1
- package/dist/react-native/sender.js +33 -11
- package/dist/react-native/sender.js.map +1 -1
- package/dist/react-native/serializers/queueResourceSerializer.js +9 -1
- package/dist/react-native/serializers/queueResourceSerializer.js.map +1 -1
- package/dist/react-native/serializers/ruleResourceSerializer.js +1 -2
- package/dist/react-native/serializers/ruleResourceSerializer.js.map +1 -1
- package/dist/react-native/serviceBusAtomManagementClient.js +181 -228
- package/dist/react-native/serviceBusAtomManagementClient.js.map +1 -1
- package/dist/react-native/serviceBusClient.js +31 -22
- package/dist/react-native/serviceBusClient.js.map +1 -1
- package/dist/react-native/serviceBusError.js +21 -1
- package/dist/react-native/serviceBusError.js.map +1 -1
- package/dist/react-native/serviceBusMessage.js +208 -13
- package/dist/react-native/serviceBusMessage.js.map +1 -1
- package/dist/react-native/serviceBusMessageBatch.js +32 -8
- package/dist/react-native/serviceBusMessageBatch.js.map +1 -1
- package/dist/react-native/serviceBusRuleManager.js +39 -15
- package/dist/react-native/serviceBusRuleManager.js.map +1 -1
- package/dist/react-native/session/messageSession.js +130 -25
- package/dist/react-native/session/messageSession.js.map +1 -1
- package/dist/react-native/util/atomXmlHelper.js +4 -5
- package/dist/react-native/util/atomXmlHelper.js.map +1 -1
- package/dist/react-native/util/compat/httpHeaders.js +1 -0
- package/dist/react-native/util/compat/httpHeaders.js.map +1 -1
- package/dist/react-native/util/constants.js +1 -1
- package/dist/react-native/util/constants.js.map +1 -1
- package/dist/react-native/util/sasServiceClientCredentials.js +8 -0
- package/dist/react-native/util/sasServiceClientCredentials.js.map +1 -1
- package/dist/react-native/util/semaphore.js +6 -2
- package/dist/react-native/util/semaphore.js.map +1 -1
- package/dist/react-native/util/utils.js +5 -7
- package/dist/react-native/util/utils.js.map +1 -1
- package/package.json +38 -38
|
@@ -32,6 +32,26 @@ exports.MaxDeleteMessageCount = 500;
|
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
34
|
class ServiceBusReceiverImpl {
|
|
35
|
+
_context;
|
|
36
|
+
entityPath;
|
|
37
|
+
receiveMode;
|
|
38
|
+
skipParsingBodyAsJson;
|
|
39
|
+
skipConvertingDate;
|
|
40
|
+
identifier;
|
|
41
|
+
_retryOptions;
|
|
42
|
+
/**
|
|
43
|
+
* Denotes if close() was called on this receiver
|
|
44
|
+
*/
|
|
45
|
+
_isClosed = false;
|
|
46
|
+
/**
|
|
47
|
+
* Instance of the BatchingReceiver class to use to receive messages in pull mode.
|
|
48
|
+
*/
|
|
49
|
+
_batchingReceiver;
|
|
50
|
+
/**
|
|
51
|
+
* Instance of the StreamingReceiver class to use to receive messages in push mode.
|
|
52
|
+
*/
|
|
53
|
+
_streamingReceiver;
|
|
54
|
+
_lockRenewer;
|
|
35
55
|
get logPrefix() {
|
|
36
56
|
return `[${this._context.connectionId}|receiver:${this.entityPath}]`;
|
|
37
57
|
}
|
|
@@ -44,10 +64,6 @@ class ServiceBusReceiverImpl {
|
|
|
44
64
|
this.receiveMode = receiveMode;
|
|
45
65
|
this.skipParsingBodyAsJson = skipParsingBodyAsJson;
|
|
46
66
|
this.skipConvertingDate = skipConvertingDate;
|
|
47
|
-
/**
|
|
48
|
-
* Denotes if close() was called on this receiver
|
|
49
|
-
*/
|
|
50
|
-
this._isClosed = false;
|
|
51
67
|
(0, errors_js_1.throwErrorIfConnectionClosed)(_context);
|
|
52
68
|
this._retryOptions = retryOptions;
|
|
53
69
|
this._lockRenewer = autoLockRenewer_js_1.LockRenewer.create(this._context, maxAutoRenewLockDurationInMs, receiveMode);
|
|
@@ -82,7 +98,6 @@ class ServiceBusReceiverImpl {
|
|
|
82
98
|
throw new TypeError(errors_js_1.InvalidMaxMessageCountError);
|
|
83
99
|
}
|
|
84
100
|
const receiveMessages = async () => {
|
|
85
|
-
var _a;
|
|
86
101
|
if (!this._batchingReceiver || !this._context.messageReceivers[this._batchingReceiver.name]) {
|
|
87
102
|
const receiveOptions = {
|
|
88
103
|
maxConcurrentCalls: 0,
|
|
@@ -93,7 +108,7 @@ class ServiceBusReceiverImpl {
|
|
|
93
108
|
};
|
|
94
109
|
this._batchingReceiver = this._createBatchingReceiver(this._context, this.entityPath, receiveOptions);
|
|
95
110
|
}
|
|
96
|
-
const receivedMessages = await this._batchingReceiver.receive(maxMessageCount,
|
|
111
|
+
const receivedMessages = await this._batchingReceiver.receive(maxMessageCount, options?.maxWaitTimeInMs ?? core_amqp_1.Constants.defaultOperationTimeoutInMs, exports.defaultMaxTimeAfterFirstMessageForBatchingMs, options ?? {});
|
|
97
112
|
return receivedMessages;
|
|
98
113
|
};
|
|
99
114
|
const config = {
|
|
@@ -101,7 +116,7 @@ class ServiceBusReceiverImpl {
|
|
|
101
116
|
connectionId: this._context.connectionId,
|
|
102
117
|
operation: receiveMessages,
|
|
103
118
|
operationType: core_amqp_1.RetryOperationType.receiveMessage,
|
|
104
|
-
abortSignal: options
|
|
119
|
+
abortSignal: options?.abortSignal,
|
|
105
120
|
retryOptions: this._retryOptions,
|
|
106
121
|
};
|
|
107
122
|
return (0, core_amqp_1.retry)(config).catch((err) => {
|
|
@@ -121,7 +136,14 @@ class ServiceBusReceiverImpl {
|
|
|
121
136
|
const receiveDeferredMessagesOperationPromise = async () => {
|
|
122
137
|
const deferredMessages = await this._context
|
|
123
138
|
.getManagementClient(this.entityPath)
|
|
124
|
-
.receiveDeferredMessages(deferredSequenceNumbers, this.receiveMode, undefined,
|
|
139
|
+
.receiveDeferredMessages(deferredSequenceNumbers, this.receiveMode, undefined, {
|
|
140
|
+
...options,
|
|
141
|
+
associatedLinkName: this._getAssociatedReceiverName(),
|
|
142
|
+
requestName: "receiveDeferredMessages",
|
|
143
|
+
timeoutInMs: this._retryOptions.timeoutInMs,
|
|
144
|
+
skipParsingBodyAsJson: this.skipParsingBodyAsJson,
|
|
145
|
+
skipConvertingDate: this.skipConvertingDate,
|
|
146
|
+
});
|
|
125
147
|
return deferredMessages;
|
|
126
148
|
};
|
|
127
149
|
const config = {
|
|
@@ -129,7 +151,7 @@ class ServiceBusReceiverImpl {
|
|
|
129
151
|
connectionId: this._context.connectionId,
|
|
130
152
|
operationType: core_amqp_1.RetryOperationType.management,
|
|
131
153
|
retryOptions: this._retryOptions,
|
|
132
|
-
abortSignal: options
|
|
154
|
+
abortSignal: options?.abortSignal,
|
|
133
155
|
};
|
|
134
156
|
return (0, core_amqp_1.retry)(config);
|
|
135
157
|
}
|
|
@@ -138,21 +160,26 @@ class ServiceBusReceiverImpl {
|
|
|
138
160
|
const deleteMessagesOperationPromise = () => {
|
|
139
161
|
return this._context
|
|
140
162
|
.getManagementClient(this.entityPath)
|
|
141
|
-
.deleteMessages(options.maxMessageCount, options
|
|
163
|
+
.deleteMessages(options.maxMessageCount, options?.beforeEnqueueTime, undefined, {
|
|
164
|
+
...options,
|
|
165
|
+
associatedLinkName: this._getAssociatedReceiverName(),
|
|
166
|
+
requestName: "deleteMessages",
|
|
167
|
+
timeoutInMs: this._retryOptions.timeoutInMs,
|
|
168
|
+
});
|
|
142
169
|
};
|
|
143
170
|
const config = {
|
|
144
171
|
operation: deleteMessagesOperationPromise,
|
|
145
172
|
connectionId: this._context.connectionId,
|
|
146
173
|
operationType: core_amqp_1.RetryOperationType.management,
|
|
147
174
|
retryOptions: this._retryOptions,
|
|
148
|
-
abortSignal: options
|
|
175
|
+
abortSignal: options?.abortSignal,
|
|
149
176
|
};
|
|
150
177
|
return (0, core_amqp_1.retry)(config);
|
|
151
178
|
}
|
|
152
179
|
async purgeMessages(options) {
|
|
153
180
|
let deletedCount = await this.deleteMessages({
|
|
154
181
|
maxMessageCount: exports.MaxDeleteMessageCount,
|
|
155
|
-
beforeEnqueueTime: options
|
|
182
|
+
beforeEnqueueTime: options?.beforeEnqueueTime,
|
|
156
183
|
});
|
|
157
184
|
log_js_1.receiverLogger.verbose(`${this.logPrefix} receiver '${this.identifier}' deleted ${deletedCount} messages.`);
|
|
158
185
|
if (deletedCount === exports.MaxDeleteMessageCount) {
|
|
@@ -160,7 +187,7 @@ class ServiceBusReceiverImpl {
|
|
|
160
187
|
while (batchCount === exports.MaxDeleteMessageCount) {
|
|
161
188
|
batchCount = await this.deleteMessages({
|
|
162
189
|
maxMessageCount: exports.MaxDeleteMessageCount,
|
|
163
|
-
beforeEnqueueTime: options
|
|
190
|
+
beforeEnqueueTime: options?.beforeEnqueueTime,
|
|
164
191
|
});
|
|
165
192
|
log_js_1.receiverLogger.verbose(`${this.logPrefix} receiver '${this.identifier}' deleted ${batchCount} messages.`);
|
|
166
193
|
deletedCount += batchCount;
|
|
@@ -171,9 +198,15 @@ class ServiceBusReceiverImpl {
|
|
|
171
198
|
}
|
|
172
199
|
// ManagementClient methods # Begin
|
|
173
200
|
async peekMessages(maxMessageCount, options = {}) {
|
|
174
|
-
var _a;
|
|
175
201
|
this._throwIfReceiverOrConnectionClosed();
|
|
176
|
-
const managementRequestOptions =
|
|
202
|
+
const managementRequestOptions = {
|
|
203
|
+
...options,
|
|
204
|
+
associatedLinkName: this._getAssociatedReceiverName(),
|
|
205
|
+
requestName: "peekMessages",
|
|
206
|
+
timeoutInMs: this._retryOptions?.timeoutInMs,
|
|
207
|
+
skipParsingBodyAsJson: this.skipParsingBodyAsJson,
|
|
208
|
+
skipConvertingDate: this.skipConvertingDate,
|
|
209
|
+
};
|
|
177
210
|
// omitMessageBody is available at runtime, but only exported in experimental subpath
|
|
178
211
|
const { fromSequenceNumber, omitMessageBody } = options;
|
|
179
212
|
const peekOperationPromise = async () => {
|
|
@@ -193,17 +226,19 @@ class ServiceBusReceiverImpl {
|
|
|
193
226
|
connectionId: this._context.connectionId,
|
|
194
227
|
operationType: core_amqp_1.RetryOperationType.management,
|
|
195
228
|
retryOptions: this._retryOptions,
|
|
196
|
-
abortSignal: options
|
|
229
|
+
abortSignal: options?.abortSignal,
|
|
197
230
|
};
|
|
198
231
|
return (0, core_amqp_1.retry)(config);
|
|
199
232
|
}
|
|
200
233
|
subscribe(handlers, options) {
|
|
201
|
-
var _a, _b;
|
|
202
234
|
(0, receiverCommon_js_1.assertValidMessageHandlers)(handlers);
|
|
203
235
|
(0, errors_js_1.throwErrorIfConnectionClosed)(this._context);
|
|
204
236
|
this._throwIfReceiverOrConnectionClosed();
|
|
205
237
|
this._throwIfAlreadyReceiving();
|
|
206
|
-
options =
|
|
238
|
+
options = {
|
|
239
|
+
...(options ?? {}),
|
|
240
|
+
autoCompleteMessages: options?.autoCompleteMessages ?? true,
|
|
241
|
+
};
|
|
207
242
|
// When the user "stops" a streaming receiver (via the returned instance from 'subscribe' we just suspend
|
|
208
243
|
// it, leaving the link open). This allows users to stop the flow of messages but still be able to settle messages
|
|
209
244
|
// since the link itself hasn't been shut down.
|
|
@@ -214,7 +249,15 @@ class ServiceBusReceiverImpl {
|
|
|
214
249
|
// 2. subscription.stop()
|
|
215
250
|
// 3. receiver.subscribe()
|
|
216
251
|
this._streamingReceiver =
|
|
217
|
-
|
|
252
|
+
this._streamingReceiver ??
|
|
253
|
+
new streamingReceiver_js_1.StreamingReceiver(this.identifier, this._context, this.entityPath, {
|
|
254
|
+
...options,
|
|
255
|
+
receiveMode: this.receiveMode,
|
|
256
|
+
retryOptions: this._retryOptions,
|
|
257
|
+
lockRenewer: this._lockRenewer,
|
|
258
|
+
skipParsingBodyAsJson: this.skipParsingBodyAsJson,
|
|
259
|
+
skipConvertingDate: this.skipConvertingDate,
|
|
260
|
+
});
|
|
218
261
|
// this ensures that if the outer service bus client is closed that this receiver is cleaned up.
|
|
219
262
|
// this mostly affects us if we're in the middle of init() - the connection (and receiver) are not yet
|
|
220
263
|
// open but we do need to close the receiver to exit the init() loop.
|
|
@@ -227,8 +270,7 @@ class ServiceBusReceiverImpl {
|
|
|
227
270
|
});
|
|
228
271
|
return {
|
|
229
272
|
close: async () => {
|
|
230
|
-
|
|
231
|
-
return (_a = this._streamingReceiver) === null || _a === void 0 ? void 0 : _a.stopReceivingMessages();
|
|
273
|
+
return this._streamingReceiver?.stopReceivingMessages();
|
|
232
274
|
},
|
|
233
275
|
};
|
|
234
276
|
}
|
|
@@ -266,7 +308,7 @@ class ServiceBusReceiverImpl {
|
|
|
266
308
|
let associatedLinkName;
|
|
267
309
|
if (msgImpl.delivery.link) {
|
|
268
310
|
const associatedReceiver = this._context.getReceiverFromCache(msgImpl.delivery.link.name);
|
|
269
|
-
associatedLinkName = associatedReceiver
|
|
311
|
+
associatedLinkName = associatedReceiver?.name;
|
|
270
312
|
}
|
|
271
313
|
return this._context
|
|
272
314
|
.getManagementClient(this.entityPath)
|
|
@@ -275,7 +317,10 @@ class ServiceBusReceiverImpl {
|
|
|
275
317
|
message.lockedUntilUtc = lockedUntil;
|
|
276
318
|
return lockedUntil;
|
|
277
319
|
});
|
|
278
|
-
},
|
|
320
|
+
}, {
|
|
321
|
+
spanLinks,
|
|
322
|
+
...(0, tracing_js_1.toSpanOptions)({ entityPath: this.entityPath, host: this._context.config.host }, "receive", "client"),
|
|
323
|
+
});
|
|
279
324
|
}
|
|
280
325
|
async close() {
|
|
281
326
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"receiver.js","sourceRoot":"","sources":["../../../src/receivers/receiver.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAclC,iDAS2B;AAE3B,uEAAiE;AACjE,qEAA+D;AAC/D,2DAO6B;AAI7B,gDAAwE;AACxE,mEAAyD;AACzD,sCAAqD;AACrD,8DAAiE;AACjE,+CAAyD;AACzD,0DAAyE;AACzE,kGAAwG;AAGxG;;;;;;;GAOG;AACU,QAAA,4CAA4C,GAAG,IAAI,CAAC;AAEjE;;;GAGG;AACU,QAAA,qBAAqB,GAAG,GAAG,CAAC;AAgPzC;;GAEG;AACH,MAAa,sBAAsB;IAmBjC,IAAY,SAAS;QACnB,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,aAAa,IAAI,CAAC,UAAU,GAAG,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,YACU,QAA2B,EAC5B,UAAkB,EAClB,WAA4C,EACnD,4BAAoC,EAC5B,qBAA8B,EAC9B,qBAA8B,KAAK,EAC3C,eAA6B,EAAE,EAC/B,UAAmB;QAPX,aAAQ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vB,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE;YAChC,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,EACzC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IACE,IAAI,CAAC,iBAAiB;YACtB,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;YAC/B,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAC1C,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,uBAAuB,CAC7B,OAA0B,EAC1B,UAAkB,EAClB,OAAuB;QAEvB,MAAM,QAAQ,GAAG,sCAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACxF,uBAAM,CAAC,OAAO,CACZ,IAAI,IAAI,CAAC,SAAS,eAAe,QAAQ,CAAC,IAAI,6CAA6C,OAAO,CAAC,kBAAkB,GAAG,CACzH,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,0BAA0B;QAChC,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC;YAChE,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACtC,CAAC;QACD,IACE,IAAI,CAAC,iBAAiB;YACtB,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;YAC/B,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAC1C,CAAC;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;QACrC,CAAC;QACD,OAAO;IACT,CAAC;CACF;AA3eD,wDA2eC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PeekMessagesOptions,\n GetMessageIteratorOptions,\n MessageHandlers,\n ReceiveMessagesOptions,\n SubscribeOptions,\n DeleteMessagesOptions,\n PurgeMessagesOptions,\n} from \"../models.js\";\nimport type { OperationOptionsBase } from \"../modelsToBeSharedWithEventHubs.js\";\nimport type { ServiceBusReceivedMessage } from \"../serviceBusMessage.js\";\nimport type { ConnectionContext } from \"../connectionContext.js\";\nimport {\n getAlreadyReceivingErrorMsg,\n getReceiverClosedErrorMsg,\n InvalidMaxMessageCountError,\n throwErrorIfConnectionClosed,\n throwTypeErrorIfParameterMissing,\n throwTypeErrorIfParameterNotLong,\n throwErrorIfInvalidOperationOnMessage,\n throwTypeErrorIfParameterTypeMismatch,\n} from \"../util/errors.js\";\nimport type { ReceiveOptions } from \"../core/messageReceiver.js\";\nimport { StreamingReceiver } from \"../core/streamingReceiver.js\";\nimport { BatchingReceiver } from \"../core/batchingReceiver.js\";\nimport {\n abandonMessage,\n assertValidMessageHandlers,\n completeMessage,\n deadLetterMessage,\n deferMessage,\n getMessageIterator,\n} from \"./receiverCommon.js\";\nimport type Long from \"long\";\nimport type { ServiceBusMessageImpl, DeadLetterOptions } from \"../serviceBusMessage.js\";\nimport type { RetryConfig, RetryOptions } from \"@azure/core-amqp\";\nimport { Constants, RetryOperationType, retry } from \"@azure/core-amqp\";\nimport { LockRenewer } from \"../core/autoLockRenewer.js\";\nimport { receiverLogger as logger } from \"../log.js\";\nimport { translateServiceBusError } from \"../serviceBusError.js\";\nimport { ensureValidIdentifier } from \"../util/utils.js\";\nimport { toSpanOptions, tracingClient } from \"../diagnostics/tracing.js\";\nimport { extractSpanContextFromServiceBusMessage } from \"../diagnostics/instrumentServiceBusMessage.js\";\nimport type { TracingSpanLink } from \"@azure/core-tracing\";\n\n/**\n * The default time to wait for messages _after_ the first message\n * has been received.\n *\n * This timeout only applies to receiveMessages()\n *\n * @internal\n */\nexport const defaultMaxTimeAfterFirstMessageForBatchingMs = 1000;\n\n/**\n * The maximum number of messages to delete in a single batch. This cap is established and enforced by the service.\n * @internal\n */\nexport const MaxDeleteMessageCount = 500;\n\n/**\n * A receiver that does not handle sessions.\n */\nexport interface ServiceBusReceiver {\n /**\n * A name used to identify the receiver. This can be used to correlate logs and exceptions.\n * If not specified or empty, a random unique one will be generated.\n */\n identifier: string;\n\n /**\n * Streams messages to message handlers.\n * @param handlers - A handler that gets called for messages and errors.\n * @param options - Options for subscribe.\n * @returns An object that can be closed, sending any remaining messages to `handlers` and\n * stopping new messages from arriving.\n */\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n /**\n * Causes the subscriber to stop receiving new messages.\n */\n close(): Promise<void>;\n };\n\n /**\n * Returns an iterator that can be used to receive messages from Service Bus.\n *\n * @param options - A set of options to control the receive operation.\n * - `abortSignal`: The signal to use to abort the ongoing operation.\n *\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws Error if current receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages.\n */\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage>;\n\n /**\n * Returns a promise that resolves to an array of messages received from Service Bus.\n *\n * @param maxMessageCount - The maximum number of messages to receive.\n * @param options - A set of options to control the receive operation.\n * - `maxWaitTimeInMs`: The maximum time to wait for the first message before returning an empty array if no messages are available.\n * - `abortSignal`: The signal to use to abort the ongoing operation.\n * @returns A promise that resolves with an array of messages.\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws Error if current receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages.\n */\n receiveMessages(\n maxMessageCount: number,\n options?: ReceiveMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Returns a promise that resolves to an array of deferred messages identified by given `sequenceNumbers`.\n * @param sequenceNumbers - The sequence number or an array of sequence numbers for the messages that need to be received.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns A list of messages identified by the given sequenceNumbers or an empty list if no messages are found.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while receiving deferred messages.\n */\n receiveDeferredMessages(\n sequenceNumbers: Long | Long[],\n options?: OperationOptionsBase,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Peek the next batch of active messages (including deferred but not deadlettered messages) on the\n * queue or subscription without modifying them.\n * - The first call to `peekMessages()` fetches the first active message. Each subsequent call fetches the\n * subsequent message.\n * - Unlike a \"received\" message, \"peeked\" message is a read-only version of the message.\n * It cannot be `Completed/Abandoned/Deferred/Deadlettered`.\n * @param maxMessageCount - The maximum number of messages to peek.\n * @param options - Options that allow to specify the maximum number of messages to peek,\n * the sequenceNumber to start peeking from or an abortSignal to abort the operation.\n */\n peekMessages(\n maxMessageCount: number,\n options?: PeekMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Delete messages. If no option is specified, all messages will be deleted.\n *\n * @param options - Options to configure the operation.\n * @returns number of messages that have been deleted.\n */\n deleteMessages(options: DeleteMessagesOptions): Promise<number>;\n\n /**\n * Attempts to purge all messages from an entity. Locked messages are not eligible for removal and\n * will remain in the entity.\n *\n * @param options - Options that allow to specify the cutoff time for deletion. Only messages that were enqueued\n * before this time will be deleted. If not specified, current time will be used.\n * @returns number of messages deleted.\n */\n purgeMessages(options?: PurgeMessagesOptions): Promise<number>;\n\n /**\n * Path of the entity for which the receiver has been created.\n */\n entityPath: string;\n /**\n * The receive mode used to create the receiver.\n */\n receiveMode: \"peekLock\" | \"receiveAndDelete\";\n /**\n * Returns `true` if either the receiver or the client that created it has been closed.\n * @readonly\n */\n isClosed: boolean;\n /**\n * Closes the receiver.\n * Once closed, the receiver cannot be used for any further operations.\n * Use the `createReceiver()` method on the ServiceBusClient to create a new Receiver.\n */\n close(): Promise<void>;\n /**\n * Removes the message from Service Bus.\n *\n * @throws Error with name `SessionLockLostError` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws Error with name `MessageLockLostError` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws Error with name `ServiceUnavailableError` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n */\n completeMessage(message: ServiceBusReceivedMessage): Promise<void>;\n /**\n * The lock held on the message by the receiver is let go, making the message available again in\n * Service Bus for another receive operation.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param propertiesToModify - The properties of the message to modify while abandoning the message.\n */\n abandonMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Defers the processing of the message. Save the `sequenceNumber` of the message, in order to\n * receive it message again in the future using the `receiveDeferredMessage` method.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param propertiesToModify - The properties of the message to modify while deferring the message\n */\n deferMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Moves the message to the deadletter sub-queue. To receive a deadletted message, create a new\n * QueueClient/SubscriptionClient using the path for the deadletter sub-queue.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param options - The DeadLetter options that can be provided while\n * rejecting the message.\n */\n deadLetterMessage(\n message: ServiceBusReceivedMessage,\n options?: DeadLetterOptions & { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Renews the lock on the message for the duration as specified during the Queue/Subscription\n * creation.\n * - Check the `lockedUntilUtc` property on the message for the time when the lock expires.\n * - If a message is not settled (using either `complete()`, `defer()` or `deadletter()`,\n * before its lock expires, then the message lands back in the Queue/Subscription for the next\n * receive operation.\n *\n * @returns New lock token expiry date and time in UTC format.\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws ServiceBusError if the service returns an error while renewing message lock.\n */\n renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusReceiverImpl implements ServiceBusReceiver {\n public identifier: string;\n private _retryOptions: RetryOptions;\n /**\n * Denotes if close() was called on this receiver\n */\n private _isClosed: boolean = false;\n\n /**\n * Instance of the BatchingReceiver class to use to receive messages in pull mode.\n */\n private _batchingReceiver?: BatchingReceiver;\n\n /**\n * Instance of the StreamingReceiver class to use to receive messages in push mode.\n */\n private _streamingReceiver?: StreamingReceiver;\n private _lockRenewer: LockRenewer | undefined;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|receiver:${this.entityPath}]`;\n }\n\n /**\n * @throws Error if the underlying connection is closed.\n */\n constructor(\n private _context: ConnectionContext,\n public entityPath: string,\n public receiveMode: \"peekLock\" | \"receiveAndDelete\",\n maxAutoRenewLockDurationInMs: number,\n private skipParsingBodyAsJson: boolean,\n private skipConvertingDate: boolean = false,\n retryOptions: RetryOptions = {},\n identifier?: string,\n ) {\n throwErrorIfConnectionClosed(_context);\n this._retryOptions = retryOptions;\n this._lockRenewer = LockRenewer.create(\n this._context,\n maxAutoRenewLockDurationInMs,\n receiveMode,\n );\n this.identifier = ensureValidIdentifier(this.entityPath, identifier);\n }\n\n private _throwIfAlreadyReceiving(): void {\n if (this._isReceivingMessages()) {\n const errorMessage = getAlreadyReceivingErrorMsg(this.entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is already receiving`);\n throw error;\n }\n }\n\n private _throwIfReceiverOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n const errorMessage = getReceiverClosedErrorMsg(this.entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is closed`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n async receiveMessages(\n maxMessageCount: number,\n options?: ReceiveMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"maxMessageCount\",\n maxMessageCount,\n );\n throwTypeErrorIfParameterTypeMismatch(\n this._context.connectionId,\n \"maxMessageCount\",\n maxMessageCount,\n \"number\",\n );\n\n if (isNaN(maxMessageCount) || maxMessageCount < 1) {\n throw new TypeError(InvalidMaxMessageCountError);\n }\n\n const receiveMessages = async (): Promise<ServiceBusReceivedMessage[]> => {\n if (!this._batchingReceiver || !this._context.messageReceivers[this._batchingReceiver.name]) {\n const receiveOptions: ReceiveOptions = {\n maxConcurrentCalls: 0,\n receiveMode: this.receiveMode,\n lockRenewer: this._lockRenewer,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n };\n this._batchingReceiver = this._createBatchingReceiver(\n this._context,\n this.entityPath,\n receiveOptions,\n );\n }\n\n const receivedMessages = await this._batchingReceiver.receive(\n maxMessageCount,\n options?.maxWaitTimeInMs ?? Constants.defaultOperationTimeoutInMs,\n defaultMaxTimeAfterFirstMessageForBatchingMs,\n options ?? {},\n );\n\n return receivedMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n connectionHost: this._context.config.host,\n connectionId: this._context.connectionId,\n operation: receiveMessages,\n operationType: RetryOperationType.receiveMessage,\n abortSignal: options?.abortSignal,\n retryOptions: this._retryOptions,\n };\n return retry<ServiceBusReceivedMessage[]>(config).catch((err) => {\n throw translateServiceBusError(err);\n });\n }\n\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage> {\n return getMessageIterator(this, options);\n }\n\n async receiveDeferredMessages(\n sequenceNumbers: Long | Long[],\n options: OperationOptionsBase = {},\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n throwTypeErrorIfParameterNotLong(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n\n const deferredSequenceNumbers = Array.isArray(sequenceNumbers)\n ? sequenceNumbers\n : [sequenceNumbers];\n const receiveDeferredMessagesOperationPromise = async (): Promise<\n ServiceBusReceivedMessage[]\n > => {\n const deferredMessages = await this._context\n .getManagementClient(this.entityPath)\n .receiveDeferredMessages(deferredSequenceNumbers, this.receiveMode, undefined, {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"receiveDeferredMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n });\n return deferredMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: receiveDeferredMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config);\n }\n\n async deleteMessages(options: DeleteMessagesOptions): Promise<number> {\n this._throwIfReceiverOrConnectionClosed();\n\n const deleteMessagesOperationPromise = (): Promise<number> => {\n return this._context\n .getManagementClient(this.entityPath)\n .deleteMessages(options.maxMessageCount, options?.beforeEnqueueTime, undefined, {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"deleteMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<number> = {\n operation: deleteMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<number>(config);\n }\n\n async purgeMessages(options?: PurgeMessagesOptions): Promise<number> {\n let deletedCount = await this.deleteMessages({\n maxMessageCount: MaxDeleteMessageCount,\n beforeEnqueueTime: options?.beforeEnqueueTime,\n });\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' deleted ${deletedCount} messages.`,\n );\n if (deletedCount === MaxDeleteMessageCount) {\n let batchCount = MaxDeleteMessageCount;\n while (batchCount === MaxDeleteMessageCount) {\n batchCount = await this.deleteMessages({\n maxMessageCount: MaxDeleteMessageCount,\n beforeEnqueueTime: options?.beforeEnqueueTime,\n });\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' deleted ${batchCount} messages.`,\n );\n deletedCount += batchCount;\n }\n }\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' purged ${deletedCount} messages.`,\n );\n return deletedCount;\n }\n\n // ManagementClient methods # Begin\n\n async peekMessages(\n maxMessageCount: number,\n options: PeekMessagesOptions = {},\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n\n const managementRequestOptions = {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"peekMessages\",\n timeoutInMs: this._retryOptions?.timeoutInMs,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n };\n // omitMessageBody is available at runtime, but only exported in experimental subpath\n const { fromSequenceNumber, omitMessageBody } = options as PeekMessagesOptions & {\n omitMessageBody: boolean;\n };\n const peekOperationPromise = async (): Promise<ServiceBusReceivedMessage[]> => {\n if (fromSequenceNumber !== undefined) {\n return this._context\n .getManagementClient(this.entityPath)\n .peekBySequenceNumber(\n fromSequenceNumber,\n maxMessageCount,\n undefined,\n omitMessageBody,\n managementRequestOptions,\n );\n } else {\n return this._context\n .getManagementClient(this.entityPath)\n .peek(maxMessageCount, omitMessageBody, managementRequestOptions);\n }\n };\n\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: peekOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config);\n }\n\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n close(): Promise<void>;\n } {\n assertValidMessageHandlers(handlers);\n throwErrorIfConnectionClosed(this._context);\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n\n options = {\n ...(options ?? {}),\n autoCompleteMessages: options?.autoCompleteMessages ?? true,\n };\n\n // When the user \"stops\" a streaming receiver (via the returned instance from 'subscribe' we just suspend\n // it, leaving the link open). This allows users to stop the flow of messages but still be able to settle messages\n // since the link itself hasn't been shut down.\n //\n // Users can, if they want, restart their subscription (since we've got a link already established).\n // So you'll have an instance here if the user has done:\n // 1. const subscription = receiver.subscribe()\n // 2. subscription.stop()\n // 3. receiver.subscribe()\n\n this._streamingReceiver =\n this._streamingReceiver ??\n new StreamingReceiver(this.identifier, this._context, this.entityPath, {\n ...options,\n receiveMode: this.receiveMode,\n retryOptions: this._retryOptions,\n lockRenewer: this._lockRenewer,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n });\n\n // this ensures that if the outer service bus client is closed that this receiver is cleaned up.\n // this mostly affects us if we're in the middle of init() - the connection (and receiver) are not yet\n // open but we do need to close the receiver to exit the init() loop.\n this._context.messageReceivers[this._streamingReceiver.name] = this._streamingReceiver;\n\n this._streamingReceiver.subscribe(handlers, options).catch((_) => {\n // (the error will already have been reported to the user)\n if (this._streamingReceiver) {\n delete this._context.messageReceivers[this._streamingReceiver.name];\n }\n });\n\n return {\n close: async (): Promise<void> => {\n return this._streamingReceiver?.stopReceivingMessages();\n },\n };\n }\n\n async completeMessage(message: ServiceBusReceivedMessage): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return completeMessage(msgImpl, this._context, this.entityPath, this._retryOptions);\n }\n\n async abandonMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return abandonMessage(\n msgImpl,\n this._context,\n this.entityPath,\n propertiesToModify,\n this._retryOptions,\n );\n }\n\n async deferMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return deferMessage(\n msgImpl,\n this._context,\n this.entityPath,\n propertiesToModify,\n this._retryOptions,\n );\n }\n\n async deadLetterMessage(\n message: ServiceBusReceivedMessage,\n options?: DeadLetterOptions & { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return deadLetterMessage(msgImpl, this._context, this.entityPath, options, this._retryOptions);\n }\n\n async renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n\n const tracingContext = extractSpanContextFromServiceBusMessage(message);\n const spanLinks: TracingSpanLink[] = tracingContext ? [{ tracingContext }] : [];\n\n return tracingClient.withSpan(\n \"ServiceBusReceiver.renewMessageLock\",\n {},\n () => {\n const msgImpl = message as ServiceBusMessageImpl;\n\n let associatedLinkName: string | undefined;\n if (msgImpl.delivery.link) {\n const associatedReceiver = this._context.getReceiverFromCache(msgImpl.delivery.link.name);\n associatedLinkName = associatedReceiver?.name;\n }\n return this._context\n .getManagementClient(this.entityPath)\n .renewLock(message.lockToken!, { associatedLinkName })\n .then((lockedUntil) => {\n message.lockedUntilUtc = lockedUntil;\n return lockedUntil;\n });\n },\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"receive\",\n \"client\",\n ),\n },\n );\n }\n\n async close(): Promise<void> {\n try {\n this._isClosed = true;\n if (this._context.connection && this._context.connection.isOpen()) {\n // Close the streaming receiver.\n if (this._streamingReceiver) {\n await this._streamingReceiver.close();\n }\n\n // Close the batching receiver.\n if (this._batchingReceiver) {\n await this._batchingReceiver.close();\n }\n }\n } catch (err: any) {\n logger.logError(err, `${this.logPrefix} An error occurred while closing the Receiver`);\n throw err;\n }\n }\n\n /**\n * Indicates whether the receiver is currently receiving messages or not.\n * When this returns true, new `registerMessageHandler()` or `receiveMessages()` calls cannot be made.\n */\n private _isReceivingMessages(): boolean {\n if (\n this._streamingReceiver &&\n this._streamingReceiver.isOpen() &&\n this._streamingReceiver.isSubscribeActive\n ) {\n return true;\n }\n if (\n this._batchingReceiver &&\n this._batchingReceiver.isOpen() &&\n this._batchingReceiver.isReceivingMessages\n ) {\n return true;\n }\n return false;\n }\n\n private _createBatchingReceiver(\n context: ConnectionContext,\n entityPath: string,\n options: ReceiveOptions,\n ): BatchingReceiver {\n const receiver = BatchingReceiver.create(this.identifier, context, entityPath, options);\n logger.verbose(\n `[${this.logPrefix}] receiver '${receiver.name}' created, with maxConcurrentCalls set to ${options.maxConcurrentCalls}.`,\n );\n\n return receiver;\n }\n\n /**\n * Helper function to retrieve any active receiver name, regardless of streaming or\n * batching if it exists. This is used for optimization on the service side\n */\n private _getAssociatedReceiverName(): string | undefined {\n if (this._streamingReceiver && this._streamingReceiver.isOpen()) {\n return this._streamingReceiver.name;\n }\n if (\n this._batchingReceiver &&\n this._batchingReceiver.isOpen() &&\n this._batchingReceiver.isReceivingMessages\n ) {\n return this._batchingReceiver.name;\n }\n return;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"receiver.js","sourceRoot":"","sources":["../../../src/receivers/receiver.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAclC,iDAS2B;AAE3B,uEAAiE;AACjE,qEAA+D;AAC/D,2DAO6B;AAI7B,gDAAwE;AACxE,mEAAyD;AACzD,sCAAqD;AACrD,8DAAiE;AACjE,+CAAyD;AACzD,0DAAyE;AACzE,kGAAwG;AAGxG;;;;;;;GAOG;AACU,QAAA,4CAA4C,GAAG,IAAI,CAAC;AAEjE;;;GAGG;AACU,QAAA,qBAAqB,GAAG,GAAG,CAAC;AAgPzC;;GAEG;AACH,MAAa,sBAAsB;IA2BvB;IACD;IACA;IAEC;IACA;IA/BH,UAAU,CAAS;IAClB,aAAa,CAAe;IACpC;;OAEG;IACK,SAAS,GAAY,KAAK,CAAC;IAEnC;;OAEG;IACK,iBAAiB,CAAoB;IAE7C;;OAEG;IACK,kBAAkB,CAAqB;IACvC,YAAY,CAA0B;IAE9C,IAAY,SAAS;QACnB,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,aAAa,IAAI,CAAC,UAAU,GAAG,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,YACU,QAA2B,EAC5B,UAAkB,EAClB,WAA4C,EACnD,4BAAoC,EAC5B,qBAA8B,EAC9B,qBAA8B,KAAK,EAC3C,eAA6B,EAAE,EAC/B,UAAmB;QAPX,aAAQ,GAAR,QAAQ,CAAmB;QAC5B,eAAU,GAAV,UAAU,CAAQ;QAClB,gBAAW,GAAX,WAAW,CAAiC;QAE3C,0BAAqB,GAArB,qBAAqB,CAAS;QAC9B,uBAAkB,GAAlB,kBAAkB,CAAiB;QAI3C,IAAA,wCAA4B,EA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AAU,EAAE,OAAO,CAAC,CAAC;QACxF,uBAAM,CAAC,OAAO,CACZ,IAAI,IAAI,CAAC,SAAS,eAAe,QAAQ,CAAC,IAAI,6CAA6C,OAAO,CAAC,kBAAkB,GAAG,CACzH,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,0BAA0B;QAChC,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC;YAChE,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACtC,CAAC;QACD,IACE,IAAI,CAAC,iBAAiB;YACtB,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;YAC/B,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAC1C,CAAC;YACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;QACrC,CAAC;QACD,OAAO;IACT,CAAC;CACF;AA3eD,wDA2eC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PeekMessagesOptions,\n GetMessageIteratorOptions,\n MessageHandlers,\n ReceiveMessagesOptions,\n SubscribeOptions,\n DeleteMessagesOptions,\n PurgeMessagesOptions,\n} from \"../models.js\";\nimport type { OperationOptionsBase } from \"../modelsToBeSharedWithEventHubs.js\";\nimport type { ServiceBusReceivedMessage } from \"../serviceBusMessage.js\";\nimport type { ConnectionContext } from \"../connectionContext.js\";\nimport {\n getAlreadyReceivingErrorMsg,\n getReceiverClosedErrorMsg,\n InvalidMaxMessageCountError,\n throwErrorIfConnectionClosed,\n throwTypeErrorIfParameterMissing,\n throwTypeErrorIfParameterNotLong,\n throwErrorIfInvalidOperationOnMessage,\n throwTypeErrorIfParameterTypeMismatch,\n} from \"../util/errors.js\";\nimport type { ReceiveOptions } from \"../core/messageReceiver.js\";\nimport { StreamingReceiver } from \"../core/streamingReceiver.js\";\nimport { BatchingReceiver } from \"../core/batchingReceiver.js\";\nimport {\n abandonMessage,\n assertValidMessageHandlers,\n completeMessage,\n deadLetterMessage,\n deferMessage,\n getMessageIterator,\n} from \"./receiverCommon.js\";\nimport type Long from \"long\";\nimport type { ServiceBusMessageImpl, DeadLetterOptions } from \"../serviceBusMessage.js\";\nimport type { RetryConfig, RetryOptions } from \"@azure/core-amqp\";\nimport { Constants, RetryOperationType, retry } from \"@azure/core-amqp\";\nimport { LockRenewer } from \"../core/autoLockRenewer.js\";\nimport { receiverLogger as logger } from \"../log.js\";\nimport { translateServiceBusError } from \"../serviceBusError.js\";\nimport { ensureValidIdentifier } from \"../util/utils.js\";\nimport { toSpanOptions, tracingClient } from \"../diagnostics/tracing.js\";\nimport { extractSpanContextFromServiceBusMessage } from \"../diagnostics/instrumentServiceBusMessage.js\";\nimport type { TracingSpanLink } from \"@azure/core-tracing\";\n\n/**\n * The default time to wait for messages _after_ the first message\n * has been received.\n *\n * This timeout only applies to receiveMessages()\n *\n * @internal\n */\nexport const defaultMaxTimeAfterFirstMessageForBatchingMs = 1000;\n\n/**\n * The maximum number of messages to delete in a single batch. This cap is established and enforced by the service.\n * @internal\n */\nexport const MaxDeleteMessageCount = 500;\n\n/**\n * A receiver that does not handle sessions.\n */\nexport interface ServiceBusReceiver {\n /**\n * A name used to identify the receiver. This can be used to correlate logs and exceptions.\n * If not specified or empty, a random unique one will be generated.\n */\n identifier: string;\n\n /**\n * Streams messages to message handlers.\n * @param handlers - A handler that gets called for messages and errors.\n * @param options - Options for subscribe.\n * @returns An object that can be closed, sending any remaining messages to `handlers` and\n * stopping new messages from arriving.\n */\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n /**\n * Causes the subscriber to stop receiving new messages.\n */\n close(): Promise<void>;\n };\n\n /**\n * Returns an iterator that can be used to receive messages from Service Bus.\n *\n * @param options - A set of options to control the receive operation.\n * - `abortSignal`: The signal to use to abort the ongoing operation.\n *\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws Error if current receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages.\n */\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage>;\n\n /**\n * Returns a promise that resolves to an array of messages received from Service Bus.\n *\n * @param maxMessageCount - The maximum number of messages to receive.\n * @param options - A set of options to control the receive operation.\n * - `maxWaitTimeInMs`: The maximum time to wait for the first message before returning an empty array if no messages are available.\n * - `abortSignal`: The signal to use to abort the ongoing operation.\n * @returns A promise that resolves with an array of messages.\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws Error if current receiver is already in state of receiving messages.\n * @throws `ServiceBusError` if the service returns an error while receiving messages.\n */\n receiveMessages(\n maxMessageCount: number,\n options?: ReceiveMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Returns a promise that resolves to an array of deferred messages identified by given `sequenceNumbers`.\n * @param sequenceNumbers - The sequence number or an array of sequence numbers for the messages that need to be received.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns A list of messages identified by the given sequenceNumbers or an empty list if no messages are found.\n * @throws Error if the underlying connection or receiver is closed.\n * @throws `ServiceBusError` if the service returns an error while receiving deferred messages.\n */\n receiveDeferredMessages(\n sequenceNumbers: Long | Long[],\n options?: OperationOptionsBase,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Peek the next batch of active messages (including deferred but not deadlettered messages) on the\n * queue or subscription without modifying them.\n * - The first call to `peekMessages()` fetches the first active message. Each subsequent call fetches the\n * subsequent message.\n * - Unlike a \"received\" message, \"peeked\" message is a read-only version of the message.\n * It cannot be `Completed/Abandoned/Deferred/Deadlettered`.\n * @param maxMessageCount - The maximum number of messages to peek.\n * @param options - Options that allow to specify the maximum number of messages to peek,\n * the sequenceNumber to start peeking from or an abortSignal to abort the operation.\n */\n peekMessages(\n maxMessageCount: number,\n options?: PeekMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]>;\n\n /**\n * Delete messages. If no option is specified, all messages will be deleted.\n *\n * @param options - Options to configure the operation.\n * @returns number of messages that have been deleted.\n */\n deleteMessages(options: DeleteMessagesOptions): Promise<number>;\n\n /**\n * Attempts to purge all messages from an entity. Locked messages are not eligible for removal and\n * will remain in the entity.\n *\n * @param options - Options that allow to specify the cutoff time for deletion. Only messages that were enqueued\n * before this time will be deleted. If not specified, current time will be used.\n * @returns number of messages deleted.\n */\n purgeMessages(options?: PurgeMessagesOptions): Promise<number>;\n\n /**\n * Path of the entity for which the receiver has been created.\n */\n entityPath: string;\n /**\n * The receive mode used to create the receiver.\n */\n receiveMode: \"peekLock\" | \"receiveAndDelete\";\n /**\n * Returns `true` if either the receiver or the client that created it has been closed.\n * @readonly\n */\n isClosed: boolean;\n /**\n * Closes the receiver.\n * Once closed, the receiver cannot be used for any further operations.\n * Use the `createReceiver()` method on the ServiceBusClient to create a new Receiver.\n */\n close(): Promise<void>;\n /**\n * Removes the message from Service Bus.\n *\n * @throws Error with name `SessionLockLostError` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws Error with name `MessageLockLostError` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws Error with name `ServiceUnavailableError` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n */\n completeMessage(message: ServiceBusReceivedMessage): Promise<void>;\n /**\n * The lock held on the message by the receiver is let go, making the message available again in\n * Service Bus for another receive operation.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param propertiesToModify - The properties of the message to modify while abandoning the message.\n */\n abandonMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Defers the processing of the message. Save the `sequenceNumber` of the message, in order to\n * receive it message again in the future using the `receiveDeferredMessage` method.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param propertiesToModify - The properties of the message to modify while deferring the message\n */\n deferMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Moves the message to the deadletter sub-queue. To receive a deadletted message, create a new\n * QueueClient/SubscriptionClient using the path for the deadletter sub-queue.\n *\n * @throws `ServiceBusError` with the code `SessionLockLost` (for messages from a Queue/Subscription with sessions enabled)\n * if the AMQP link with which the message was received is no longer alive. This can\n * happen either because the lock on the session expired or the receiver was explicitly closed by\n * the user or the AMQP link is closed by the library due to network loss or service error.\n * @throws `ServiceBusError` with the code `MessageLockLost` (for messages from a Queue/Subscription with sessions not enabled)\n * if the lock on the message has expired or the AMQP link with which the message was received is\n * no longer alive. The latter can happen if the receiver was explicitly closed by the user or the\n * AMQP link got closed by the library due to network loss or service error.\n * @throws Error if the message is already settled.\n * property on the message if you are not sure whether the message is settled.\n * @throws Error if used in `receiveAndDelete` mode because all messages received in this mode\n * are pre-settled. To avoid this error, update your code to not settle a message which is received\n * in this mode.\n * @throws `ServiceBusError` with the code `ServiceTimeout` if Service Bus does not acknowledge the request to settle\n * the message in time. The message may or may not have been settled successfully.\n *\n * @param options - The DeadLetter options that can be provided while\n * rejecting the message.\n */\n deadLetterMessage(\n message: ServiceBusReceivedMessage,\n options?: DeadLetterOptions & { [key: string]: number | boolean | string | Date | null },\n ): Promise<void>;\n /**\n * Renews the lock on the message for the duration as specified during the Queue/Subscription\n * creation.\n * - Check the `lockedUntilUtc` property on the message for the time when the lock expires.\n * - If a message is not settled (using either `complete()`, `defer()` or `deadletter()`,\n * before its lock expires, then the message lands back in the Queue/Subscription for the next\n * receive operation.\n *\n * @returns New lock token expiry date and time in UTC format.\n * @throws Error if the underlying connection, client or receiver is closed.\n * @throws ServiceBusError if the service returns an error while renewing message lock.\n */\n renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusReceiverImpl implements ServiceBusReceiver {\n public identifier: string;\n private _retryOptions: RetryOptions;\n /**\n * Denotes if close() was called on this receiver\n */\n private _isClosed: boolean = false;\n\n /**\n * Instance of the BatchingReceiver class to use to receive messages in pull mode.\n */\n private _batchingReceiver?: BatchingReceiver;\n\n /**\n * Instance of the StreamingReceiver class to use to receive messages in push mode.\n */\n private _streamingReceiver?: StreamingReceiver;\n private _lockRenewer: LockRenewer | undefined;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|receiver:${this.entityPath}]`;\n }\n\n /**\n * @throws Error if the underlying connection is closed.\n */\n constructor(\n private _context: ConnectionContext,\n public entityPath: string,\n public receiveMode: \"peekLock\" | \"receiveAndDelete\",\n maxAutoRenewLockDurationInMs: number,\n private skipParsingBodyAsJson: boolean,\n private skipConvertingDate: boolean = false,\n retryOptions: RetryOptions = {},\n identifier?: string,\n ) {\n throwErrorIfConnectionClosed(_context);\n this._retryOptions = retryOptions;\n this._lockRenewer = LockRenewer.create(\n this._context,\n maxAutoRenewLockDurationInMs,\n receiveMode,\n );\n this.identifier = ensureValidIdentifier(this.entityPath, identifier);\n }\n\n private _throwIfAlreadyReceiving(): void {\n if (this._isReceivingMessages()) {\n const errorMessage = getAlreadyReceivingErrorMsg(this.entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is already receiving`);\n throw error;\n }\n }\n\n private _throwIfReceiverOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n const errorMessage = getReceiverClosedErrorMsg(this.entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `${this.logPrefix} is closed`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n async receiveMessages(\n maxMessageCount: number,\n options?: ReceiveMessagesOptions,\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"maxMessageCount\",\n maxMessageCount,\n );\n throwTypeErrorIfParameterTypeMismatch(\n this._context.connectionId,\n \"maxMessageCount\",\n maxMessageCount,\n \"number\",\n );\n\n if (isNaN(maxMessageCount) || maxMessageCount < 1) {\n throw new TypeError(InvalidMaxMessageCountError);\n }\n\n const receiveMessages = async (): Promise<ServiceBusReceivedMessage[]> => {\n if (!this._batchingReceiver || !this._context.messageReceivers[this._batchingReceiver.name]) {\n const receiveOptions: ReceiveOptions = {\n maxConcurrentCalls: 0,\n receiveMode: this.receiveMode,\n lockRenewer: this._lockRenewer,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n };\n this._batchingReceiver = this._createBatchingReceiver(\n this._context,\n this.entityPath,\n receiveOptions,\n );\n }\n\n const receivedMessages = await this._batchingReceiver.receive(\n maxMessageCount,\n options?.maxWaitTimeInMs ?? Constants.defaultOperationTimeoutInMs,\n defaultMaxTimeAfterFirstMessageForBatchingMs,\n options ?? {},\n );\n\n return receivedMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n connectionHost: this._context.config.host,\n connectionId: this._context.connectionId,\n operation: receiveMessages,\n operationType: RetryOperationType.receiveMessage,\n abortSignal: options?.abortSignal,\n retryOptions: this._retryOptions,\n };\n return retry<ServiceBusReceivedMessage[]>(config).catch((err) => {\n throw translateServiceBusError(err);\n });\n }\n\n getMessageIterator(\n options?: GetMessageIteratorOptions,\n ): AsyncIterableIterator<ServiceBusReceivedMessage> {\n return getMessageIterator(this, options);\n }\n\n async receiveDeferredMessages(\n sequenceNumbers: Long | Long[],\n options: OperationOptionsBase = {},\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n throwTypeErrorIfParameterNotLong(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n\n const deferredSequenceNumbers = Array.isArray(sequenceNumbers)\n ? sequenceNumbers\n : [sequenceNumbers];\n const receiveDeferredMessagesOperationPromise = async (): Promise<\n ServiceBusReceivedMessage[]\n > => {\n const deferredMessages = await this._context\n .getManagementClient(this.entityPath)\n .receiveDeferredMessages(deferredSequenceNumbers, this.receiveMode, undefined, {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"receiveDeferredMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n });\n return deferredMessages;\n };\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: receiveDeferredMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config);\n }\n\n async deleteMessages(options: DeleteMessagesOptions): Promise<number> {\n this._throwIfReceiverOrConnectionClosed();\n\n const deleteMessagesOperationPromise = (): Promise<number> => {\n return this._context\n .getManagementClient(this.entityPath)\n .deleteMessages(options.maxMessageCount, options?.beforeEnqueueTime, undefined, {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"deleteMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<number> = {\n operation: deleteMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<number>(config);\n }\n\n async purgeMessages(options?: PurgeMessagesOptions): Promise<number> {\n let deletedCount = await this.deleteMessages({\n maxMessageCount: MaxDeleteMessageCount,\n beforeEnqueueTime: options?.beforeEnqueueTime,\n });\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' deleted ${deletedCount} messages.`,\n );\n if (deletedCount === MaxDeleteMessageCount) {\n let batchCount = MaxDeleteMessageCount;\n while (batchCount === MaxDeleteMessageCount) {\n batchCount = await this.deleteMessages({\n maxMessageCount: MaxDeleteMessageCount,\n beforeEnqueueTime: options?.beforeEnqueueTime,\n });\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' deleted ${batchCount} messages.`,\n );\n deletedCount += batchCount;\n }\n }\n logger.verbose(\n `${this.logPrefix} receiver '${this.identifier}' purged ${deletedCount} messages.`,\n );\n return deletedCount;\n }\n\n // ManagementClient methods # Begin\n\n async peekMessages(\n maxMessageCount: number,\n options: PeekMessagesOptions = {},\n ): Promise<ServiceBusReceivedMessage[]> {\n this._throwIfReceiverOrConnectionClosed();\n\n const managementRequestOptions = {\n ...options,\n associatedLinkName: this._getAssociatedReceiverName(),\n requestName: \"peekMessages\",\n timeoutInMs: this._retryOptions?.timeoutInMs,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n };\n // omitMessageBody is available at runtime, but only exported in experimental subpath\n const { fromSequenceNumber, omitMessageBody } = options as PeekMessagesOptions & {\n omitMessageBody: boolean;\n };\n const peekOperationPromise = async (): Promise<ServiceBusReceivedMessage[]> => {\n if (fromSequenceNumber !== undefined) {\n return this._context\n .getManagementClient(this.entityPath)\n .peekBySequenceNumber(\n fromSequenceNumber,\n maxMessageCount,\n undefined,\n omitMessageBody,\n managementRequestOptions,\n );\n } else {\n return this._context\n .getManagementClient(this.entityPath)\n .peek(maxMessageCount, omitMessageBody, managementRequestOptions);\n }\n };\n\n const config: RetryConfig<ServiceBusReceivedMessage[]> = {\n operation: peekOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<ServiceBusReceivedMessage[]>(config);\n }\n\n subscribe(\n handlers: MessageHandlers,\n options?: SubscribeOptions,\n ): {\n close(): Promise<void>;\n } {\n assertValidMessageHandlers(handlers);\n throwErrorIfConnectionClosed(this._context);\n this._throwIfReceiverOrConnectionClosed();\n this._throwIfAlreadyReceiving();\n\n options = {\n ...(options ?? {}),\n autoCompleteMessages: options?.autoCompleteMessages ?? true,\n };\n\n // When the user \"stops\" a streaming receiver (via the returned instance from 'subscribe' we just suspend\n // it, leaving the link open). This allows users to stop the flow of messages but still be able to settle messages\n // since the link itself hasn't been shut down.\n //\n // Users can, if they want, restart their subscription (since we've got a link already established).\n // So you'll have an instance here if the user has done:\n // 1. const subscription = receiver.subscribe()\n // 2. subscription.stop()\n // 3. receiver.subscribe()\n\n this._streamingReceiver =\n this._streamingReceiver ??\n new StreamingReceiver(this.identifier, this._context, this.entityPath, {\n ...options,\n receiveMode: this.receiveMode,\n retryOptions: this._retryOptions,\n lockRenewer: this._lockRenewer,\n skipParsingBodyAsJson: this.skipParsingBodyAsJson,\n skipConvertingDate: this.skipConvertingDate,\n });\n\n // this ensures that if the outer service bus client is closed that this receiver is cleaned up.\n // this mostly affects us if we're in the middle of init() - the connection (and receiver) are not yet\n // open but we do need to close the receiver to exit the init() loop.\n this._context.messageReceivers[this._streamingReceiver.name] = this._streamingReceiver;\n\n this._streamingReceiver.subscribe(handlers, options).catch((_) => {\n // (the error will already have been reported to the user)\n if (this._streamingReceiver) {\n delete this._context.messageReceivers[this._streamingReceiver.name];\n }\n });\n\n return {\n close: async (): Promise<void> => {\n return this._streamingReceiver?.stopReceivingMessages();\n },\n };\n }\n\n async completeMessage(message: ServiceBusReceivedMessage): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return completeMessage(msgImpl, this._context, this.entityPath, this._retryOptions);\n }\n\n async abandonMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return abandonMessage(\n msgImpl,\n this._context,\n this.entityPath,\n propertiesToModify,\n this._retryOptions,\n );\n }\n\n async deferMessage(\n message: ServiceBusReceivedMessage,\n propertiesToModify?: { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return deferMessage(\n msgImpl,\n this._context,\n this.entityPath,\n propertiesToModify,\n this._retryOptions,\n );\n }\n\n async deadLetterMessage(\n message: ServiceBusReceivedMessage,\n options?: DeadLetterOptions & { [key: string]: number | boolean | string | Date | null },\n ): Promise<void> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n const msgImpl = message as ServiceBusMessageImpl;\n return deadLetterMessage(msgImpl, this._context, this.entityPath, options, this._retryOptions);\n }\n\n async renewMessageLock(message: ServiceBusReceivedMessage): Promise<Date> {\n this._throwIfReceiverOrConnectionClosed();\n throwErrorIfInvalidOperationOnMessage(message, this.receiveMode, this._context.connectionId);\n\n const tracingContext = extractSpanContextFromServiceBusMessage(message);\n const spanLinks: TracingSpanLink[] = tracingContext ? [{ tracingContext }] : [];\n\n return tracingClient.withSpan(\n \"ServiceBusReceiver.renewMessageLock\",\n {},\n () => {\n const msgImpl = message as ServiceBusMessageImpl;\n\n let associatedLinkName: string | undefined;\n if (msgImpl.delivery.link) {\n const associatedReceiver = this._context.getReceiverFromCache(msgImpl.delivery.link.name);\n associatedLinkName = associatedReceiver?.name;\n }\n return this._context\n .getManagementClient(this.entityPath)\n .renewLock(message.lockToken!, { associatedLinkName })\n .then((lockedUntil) => {\n message.lockedUntilUtc = lockedUntil;\n return lockedUntil;\n });\n },\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"receive\",\n \"client\",\n ),\n },\n );\n }\n\n async close(): Promise<void> {\n try {\n this._isClosed = true;\n if (this._context.connection && this._context.connection.isOpen()) {\n // Close the streaming receiver.\n if (this._streamingReceiver) {\n await this._streamingReceiver.close();\n }\n\n // Close the batching receiver.\n if (this._batchingReceiver) {\n await this._batchingReceiver.close();\n }\n }\n } catch (err: any) {\n logger.logError(err, `${this.logPrefix} An error occurred while closing the Receiver`);\n throw err;\n }\n }\n\n /**\n * Indicates whether the receiver is currently receiving messages or not.\n * When this returns true, new `registerMessageHandler()` or `receiveMessages()` calls cannot be made.\n */\n private _isReceivingMessages(): boolean {\n if (\n this._streamingReceiver &&\n this._streamingReceiver.isOpen() &&\n this._streamingReceiver.isSubscribeActive\n ) {\n return true;\n }\n if (\n this._batchingReceiver &&\n this._batchingReceiver.isOpen() &&\n this._batchingReceiver.isReceivingMessages\n ) {\n return true;\n }\n return false;\n }\n\n private _createBatchingReceiver(\n context: ConnectionContext,\n entityPath: string,\n options: ReceiveOptions,\n ): BatchingReceiver {\n const receiver = BatchingReceiver.create(this.identifier, context, entityPath, options);\n logger.verbose(\n `[${this.logPrefix}] receiver '${receiver.name}' created, with maxConcurrentCalls set to ${options.maxConcurrentCalls}.`,\n );\n\n return receiver;\n }\n\n /**\n * Helper function to retrieve any active receiver name, regardless of streaming or\n * batching if it exists. This is used for optimization on the service side\n */\n private _getAssociatedReceiverName(): string | undefined {\n if (this._streamingReceiver && this._streamingReceiver.isOpen()) {\n return this._streamingReceiver.name;\n }\n if (\n this._batchingReceiver &&\n this._batchingReceiver.isOpen() &&\n this._batchingReceiver.isReceivingMessages\n ) {\n return this._batchingReceiver.name;\n }\n return;\n }\n}\n"]}
|
|
@@ -12,7 +12,6 @@ exports.deadLetterMessage = deadLetterMessage;
|
|
|
12
12
|
exports.settleMessage = settleMessage;
|
|
13
13
|
exports.settleMessageOperation = settleMessageOperation;
|
|
14
14
|
exports.retryForever = retryForever;
|
|
15
|
-
const tslib_1 = require("tslib");
|
|
16
15
|
const log_js_1 = require("../log.js");
|
|
17
16
|
const serviceBusError_js_1 = require("../serviceBusError.js");
|
|
18
17
|
const serviceBusMessage_js_1 = require("../serviceBusMessage.js");
|
|
@@ -35,16 +34,14 @@ function assertValidMessageHandlers(handlers) {
|
|
|
35
34
|
/**
|
|
36
35
|
* @internal
|
|
37
36
|
*/
|
|
38
|
-
function getMessageIterator(receiver, options) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
yield yield tslib_1.__await(messages[0]);
|
|
37
|
+
async function* getMessageIterator(receiver, options) {
|
|
38
|
+
while (true) {
|
|
39
|
+
const messages = await receiver.receiveMessages(1, options);
|
|
40
|
+
if (messages.length === 0) {
|
|
41
|
+
continue;
|
|
46
42
|
}
|
|
47
|
-
|
|
43
|
+
yield messages[0];
|
|
44
|
+
}
|
|
48
45
|
}
|
|
49
46
|
/**
|
|
50
47
|
* @internal
|
|
@@ -70,7 +67,10 @@ function completeMessage(message, context, entityPath, retryOptions) {
|
|
|
70
67
|
const spanLinks = tracingContext ? [{ tracingContext }] : [];
|
|
71
68
|
return tracing_js_1.tracingClient.withSpan("ServicebusReceiver.complete", {}, () => settleMessage(message, serviceBusMessage_js_1.DispositionType.complete, context, entityPath, {
|
|
72
69
|
retryOptions,
|
|
73
|
-
}),
|
|
70
|
+
}), {
|
|
71
|
+
spanLinks,
|
|
72
|
+
...(0, tracing_js_1.toSpanOptions)({ entityPath, host: context.config.host }, "settle", "client"),
|
|
73
|
+
});
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* @internal
|
|
@@ -83,7 +83,10 @@ function abandonMessage(message, context, entityPath, propertiesToModify, retryO
|
|
|
83
83
|
return tracing_js_1.tracingClient.withSpan("ServicebusReceiver.abandon", {}, () => settleMessage(message, serviceBusMessage_js_1.DispositionType.abandon, context, entityPath, {
|
|
84
84
|
propertiesToModify,
|
|
85
85
|
retryOptions,
|
|
86
|
-
}),
|
|
86
|
+
}), {
|
|
87
|
+
spanLinks,
|
|
88
|
+
...(0, tracing_js_1.toSpanOptions)({ entityPath, host: context.config.host }, "settle", "client"),
|
|
89
|
+
});
|
|
87
90
|
}
|
|
88
91
|
/**
|
|
89
92
|
* @internal
|
|
@@ -96,7 +99,10 @@ function deferMessage(message, context, entityPath, propertiesToModify, retryOpt
|
|
|
96
99
|
return tracing_js_1.tracingClient.withSpan("ServiceBusReceiver.defer", {}, () => settleMessage(message, serviceBusMessage_js_1.DispositionType.defer, context, entityPath, {
|
|
97
100
|
retryOptions,
|
|
98
101
|
propertiesToModify,
|
|
99
|
-
}),
|
|
102
|
+
}), {
|
|
103
|
+
spanLinks,
|
|
104
|
+
...(0, tracing_js_1.toSpanOptions)({ entityPath, host: context.config.host }, "settle", "client"),
|
|
105
|
+
});
|
|
100
106
|
}
|
|
101
107
|
/**
|
|
102
108
|
* @internal
|
|
@@ -104,19 +110,24 @@ function deferMessage(message, context, entityPath, propertiesToModify, retryOpt
|
|
|
104
110
|
*/
|
|
105
111
|
function deadLetterMessage(message, context, entityPath, propertiesToModify, retryOptions) {
|
|
106
112
|
log_js_1.receiverLogger.verbose("[%s] Deadlettering the message with id '%s'.", context.connectionId, message.messageId);
|
|
107
|
-
const actualPropertiesToModify =
|
|
113
|
+
const actualPropertiesToModify = {
|
|
114
|
+
...propertiesToModify,
|
|
115
|
+
};
|
|
108
116
|
// these two fields are handled specially and don't need to be in here.
|
|
109
117
|
delete actualPropertiesToModify.deadLetterErrorDescription;
|
|
110
118
|
delete actualPropertiesToModify.deadLetterReason;
|
|
111
119
|
const dispositionStatusOptions = {
|
|
112
120
|
propertiesToModify: actualPropertiesToModify,
|
|
113
|
-
deadLetterReason: propertiesToModify
|
|
114
|
-
deadLetterDescription: propertiesToModify
|
|
121
|
+
deadLetterReason: propertiesToModify?.deadLetterReason,
|
|
122
|
+
deadLetterDescription: propertiesToModify?.deadLetterErrorDescription,
|
|
115
123
|
retryOptions,
|
|
116
124
|
};
|
|
117
125
|
const tracingContext = (0, instrumentServiceBusMessage_js_1.extractSpanContextFromServiceBusMessage)(message);
|
|
118
126
|
const spanLinks = tracingContext ? [{ tracingContext }] : [];
|
|
119
|
-
return tracing_js_1.tracingClient.withSpan("ServiceBusReceiver.deadLetter", {}, () => settleMessage(message, serviceBusMessage_js_1.DispositionType.deadletter, context, entityPath, dispositionStatusOptions),
|
|
127
|
+
return tracing_js_1.tracingClient.withSpan("ServiceBusReceiver.deadLetter", {}, () => settleMessage(message, serviceBusMessage_js_1.DispositionType.deadletter, context, entityPath, dispositionStatusOptions), {
|
|
128
|
+
spanLinks,
|
|
129
|
+
...(0, tracing_js_1.toSpanOptions)({ entityPath, host: context.config.host }, "settle", "client"),
|
|
130
|
+
});
|
|
120
131
|
}
|
|
121
132
|
/**
|
|
122
133
|
* @internal
|
|
@@ -128,8 +139,8 @@ function settleMessage(message, operation, context, entityPath, options, _settle
|
|
|
128
139
|
return _settleMessageOperation(message, operation, context, entityPath, options);
|
|
129
140
|
},
|
|
130
141
|
operationType: core_amqp_1.RetryOperationType.messageSettlement,
|
|
131
|
-
abortSignal: options
|
|
132
|
-
retryOptions: options
|
|
142
|
+
abortSignal: options?.abortSignal,
|
|
143
|
+
retryOptions: options?.retryOptions,
|
|
133
144
|
});
|
|
134
145
|
}
|
|
135
146
|
/**
|
|
@@ -144,7 +155,7 @@ async function settleMessageOperation(message, operation, context, entityPath, o
|
|
|
144
155
|
const receiver = isDeferredMessage
|
|
145
156
|
? undefined
|
|
146
157
|
: context.getReceiverFromCache(message.delivery.link.name, message.sessionId);
|
|
147
|
-
const associatedLinkName = receiver
|
|
158
|
+
const associatedLinkName = receiver?.name;
|
|
148
159
|
let error;
|
|
149
160
|
if (message.delivery.remote_settled) {
|
|
150
161
|
error = new Error(errors_js_1.MessageAlreadySettled);
|
|
@@ -168,7 +179,11 @@ async function settleMessageOperation(message, operation, context, entityPath, o
|
|
|
168
179
|
if (isDeferredMessage || ((!receiver || !receiver.isOpen()) && !(0, core_util_1.isDefined)(message.sessionId))) {
|
|
169
180
|
return context
|
|
170
181
|
.getManagementClient(entityPath)
|
|
171
|
-
.updateDispositionStatus(message.lockToken, operation,
|
|
182
|
+
.updateDispositionStatus(message.lockToken, operation, {
|
|
183
|
+
...options,
|
|
184
|
+
associatedLinkName,
|
|
185
|
+
sessionId: message.sessionId,
|
|
186
|
+
})
|
|
172
187
|
.catch((err) => {
|
|
173
188
|
throw (0, serviceBusError_js_1.translateServiceBusError)(err);
|
|
174
189
|
});
|