Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
messageBody[Constants.sequenceNumbers].push(Buffer.from(sequenceNumber.toBytesBE()));
} catch (err) {
const error = translate(err);
log.error(
"An error occurred while encoding the item at position %d in the " +
"sequenceNumbers array: %O",
i,
error
);
throw error;
}
}
try {
messageBody[Constants.sequenceNumbers] = types.wrap_array(
messageBody[Constants.sequenceNumbers],
0x81,
undefined
);
const request: AmqpMessage = {
body: messageBody,
message_id: generate_uuid(),
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.cancelScheduledMessage
}
};
if (this._context.sender) {
request.application_properties![Constants.associatedLinkName] = this._context.sender!.name;
}
async renewLock(lockToken: string, options?: SendRequestOptions): Promise {
throwErrorIfConnectionClosed(this._context.namespace);
if (!options) options = {};
if (options.delayInSeconds == null) options.delayInSeconds = 1;
if (options.timeoutInSeconds == null) options.timeoutInSeconds = 5;
if (options.times == null) options.times = 5;
try {
const messageBody: any = {};
messageBody[Constants.lockTokens] = types.wrap_array(
[string_to_uuid(lockToken)],
0x98,
undefined
);
const request: AmqpMessage = {
body: messageBody,
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.renewLock
}
};
request.application_properties![Constants.trackingId] = generate_uuid();
const associatedLinkName = this._getAssociatedReceiverName(this._context);
if (associatedLinkName) {
request.application_properties![Constants.associatedLinkName] = associatedLinkName;
}
try {
messageBody[Constants.sequenceNumbers].push(Buffer.from(sequenceNumber.toBytesBE()));
} catch (err) {
const error = translate(err);
log.error(
"An error occurred while encoding the item at position %d in the " +
"sequenceNumbers array: %O",
i,
error
);
throw error;
}
}
try {
messageBody[Constants.sequenceNumbers] = types.wrap_array(
messageBody[Constants.sequenceNumbers],
0x81,
undefined
);
const receiverSettleMode: number = receiveMode === ReceiveMode.receiveAndDelete ? 0 : 1;
messageBody[Constants.receiverSettleMode] = types.wrap_uint(receiverSettleMode);
if (sessionId != null) {
messageBody[Constants.sessionIdMapKey] = sessionId;
}
const request: AmqpMessage = {
body: messageBody,
message_id: generate_uuid(),
reply_to: this.replyTo,
application_properties: {
operation: Constants.operations.receiveBySequenceNumber
}
async updateDispositionStatus(
lockToken: string,
dispositionStatus: DispositionStatus,
options?: DispositionStatusOptions
): Promise {
throwErrorIfConnectionClosed(this._context.namespace);
if (!options) options = {};
try {
const messageBody: any = {};
const lockTokenBuffer: Buffer[] = [];
lockTokenBuffer.push(string_to_uuid(lockToken));
messageBody[Constants.lockTokens] = types.wrap_array(lockTokenBuffer, 0x98, undefined);
messageBody[Constants.dispositionStatus] = dispositionStatus;
if (options.deadLetterDescription != null) {
messageBody[Constants.deadLetterDescription] = options.deadLetterDescription;
}
if (options.deadLetterReason != null) {
messageBody[Constants.deadLetterReason] = options.deadLetterReason;
}
if (options.propertiesToModify != null) {
messageBody[Constants.propertiesToModify] = options.propertiesToModify;
}
if (options.sessionId != null) {
messageBody[Constants.sessionIdMapKey] = options.sessionId;
}
const request: AmqpMessage = {
body: messageBody,
message_id: generate_uuid(),