Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._context.namespace.connectionId,
request.body
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);
await defaultLock.acquire(this.managementLock, () => {
return this._init();
});
const result = await this._mgmtReqResLink!.sendRequest(request);
if (result.application_properties!.statusCode !== 204) {
const messages = result.body.messages as { message: Buffer }[];
for (const msg of messages) {
const decodedMessage = RheaMessageUtil.decode(msg.message);
const message = fromAmqpMessage(decodedMessage as any);
message.body = this._context.namespace.dataTransformer.decode(message.body);
messageList.push(message);
this._lastPeekedSequenceNumber = message.sequenceNumber!;
}
}
} catch (err) {
const error = translate(err);
log.error(
"An error occurred while sending the request to peek messages to " +
"$management endpoint: %O",
error
);
// statusCode == 404 then do not throw
if (error.name !== ConditionErrorNameMapper["com.microsoft:message-not-found"]) {
throw error;
);
log.mgmt(
"[%s] Acquiring lock to get the management req res link.",
this._context.namespace.connectionId
);
await defaultLock.acquire(this.managementLock, () => {
return this._init();
});
const result = await this._mgmtReqResLink!.sendRequest(request);
const messages = result.body.messages as {
message: Buffer;
"lock-token": Buffer;
}[];
for (const msg of messages) {
const decodedMessage = RheaMessageUtil.decode(msg.message);
const message = new ServiceBusMessage(
this._context,
decodedMessage as any,
{ tag: msg["lock-token"] } as any,
false
);
if (message.lockToken && message.lockedUntilUtc) {
this._context.requestResponseLockedMessages.set(
message.lockToken,
message.lockedUntilUtc
);
}
messageList.push(message);
}
return messageList;
} catch (err) {