Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
application_properties: {
operation: Constants.operations.enumerateRules
}
};
request.application_properties![Constants.trackingId] = generate_uuid();
log.mgmt(
"[%s] Get rules request body: %O.",
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 response = await this._mgmtReqResLink!.sendRequest(request);
if (
response.application_properties!.statusCode === 204 ||
!response.body ||
!Array.isArray(response.body.rules)
) {
return [];
}
// Reference: https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-request-response#response-11
const result: { "rule-description": Typed }[] = response.body.rules || [];
const rules: RuleDescription[] = [];
result.forEach((x) => {
} else {
const state: any = {
wasCloseInitiated: wasCloseInitiated,
senderError: senderError,
_sender: this._sender
};
log.error(
"[%s] Something went wrong. State of sender '%s' with address '%s' is: %O",
this._context.namespace.connectionId,
this.name,
this.address,
state
);
}
if (shouldReopen) {
await defaultLock.acquire(this.senderLock, () => {
const options: SenderOptions = this._createSenderOptions({
newName: true
});
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: this._context.namespace.connectionId!,
operationType: RetryOperationType.senderLink,
times: Constants.defaultConnectionRetryAttempts,
connectionHost: this._context.namespace.config.host,
delayInSeconds: 15
};
return retry(config);
});
}
} else {
const state: any = {
wasCloseInitiated: wasCloseInitiated,
senderError: senderError,
_sender: this._sender
};
log.error(
"[%s] Something went wrong. State of sender '%s' with address '%s' is: %O",
this._context.namespace.connectionId,
this.name,
this.address,
state
);
}
if (shouldReopen) {
await defaultLock.acquire(this.senderLock, () => {
const options: SenderOptions = this._createSenderOptions({
newName: true
});
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: this._context.namespace.connectionId!,
operationType: RetryOperationType.senderLink,
times: Constants.defaultConnectionRetryAttempts,
connectionHost: this._context.namespace.config.host,
delayInSeconds: 15
};
return retry(config);
});
}
// if messages were received by the receiver before it got disconnected.
if (this._checkpoint.sequenceNumber > -1) {
rcvrOptions.eventPosition = EventPosition.fromSequenceNumber(this._checkpoint.sequenceNumber);
}
const options: ReceiverOptions = this._createReceiverOptions(rcvrOptions);
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: this._context.connectionId,
operationType: RetryOperationType.receiverLink,
times: Constants.defaultConnectionRetryAttempts,
connectionHost: this._context.config.host,
delayInSeconds: 15
};
await retry(config);
}
} catch (err) {
log.error(
"[%s] An error occurred while processing detached() of Receiver '%s' with address " + "'%s': %O",
this._context.connectionId,
this.name,
this.address,
err
);
}
}
await defaultLock.acquire(this.senderLock, () => {
const options: SenderOptions = this._createSenderOptions({
newName: true
});
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: this._context.namespace.connectionId!,
operationType: RetryOperationType.senderLink,
times: Constants.defaultConnectionRetryAttempts,
connectionHost: this._context.namespace.config.host,
delayInSeconds: 15
};
return retry(config);
});
}
);
}
if (shouldReopen) {
// provide a new name to the link while re-connecting it. This ensures that
// the service does not send an error stating that the link is still open.
const options: ReceiverOptions = this._createReceiverOptions(true);
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: connectionId,
operationType: RetryOperationType.receiverLink,
times: Constants.defaultConnectionRetryAttempts,
delayInSeconds: 15
};
await retry(config);
}
} catch (err) {
log.error(
"[%s] An error occurred while processing detached() of Receiver '%s': %O ",
connectionId,
this.name,
this.address,
err
);
}
}
this.name,
this.address,
state
);
}
if (shouldReopen) {
// provide a new name to the link while re-connecting it. This ensures that
// the service does not send an error stating that the link is still open.
const options: ReceiverOptions = this._createReceiverOptions(true);
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: connectionId,
operationType: RetryOperationType.receiverLink,
times: Constants.defaultConnectionRetryAttempts,
delayInSeconds: 15
};
await retry(config);
}
} catch (err) {
log.error(
"[%s] An error occurred while processing detached() of Receiver '%s': %O ",
connectionId,
this.name,
this.address,
err
);
}
}
await defaultLock.acquire(this.senderLock, () => {
const options: SenderOptions = this._createSenderOptions({
newName: true
});
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: this._context.namespace.connectionId!,
operationType: RetryOperationType.senderLink,
times: Constants.defaultConnectionRetryAttempts,
connectionHost: this._context.namespace.config.host,
delayInSeconds: 15
};
return retry(config);
});
}
newName: true // provide a new name to the link while re-connecting it. This ensures that
// the service does not send an error stating that the link is still open.
};
// reconnect the receiver link with sequenceNumber of the last received message as the offset
// if messages were received by the receiver before it got disconnected.
if (this._checkpoint.sequenceNumber > -1) {
rcvrOptions.eventPosition = EventPosition.fromSequenceNumber(this._checkpoint.sequenceNumber);
}
const options: ReceiverOptions = this._createReceiverOptions(rcvrOptions);
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: this._context.connectionId,
operationType: RetryOperationType.receiverLink,
times: Constants.defaultConnectionRetryAttempts,
connectionHost: this._context.config.host,
delayInSeconds: 15
};
await retry(config);
}
} catch (err) {
log.error(
"[%s] An error occurred while processing detached() of Receiver '%s' with address " + "'%s': %O",
this._context.connectionId,
this.name,
this.address,
err
);
}
}
await defaultLock.acquire(this.senderLock, () => {
const options: SenderOptions = this._createSenderOptions({
newName: true
});
// shall retry forever at an interval of 15 seconds if the error is a retryable error
// else bail out when the error is not retryable or the oepration succeeds.
const config: RetryConfig = {
operation: () => this._init(options),
connectionId: this._context.namespace.connectionId!,
operationType: RetryOperationType.senderLink,
times: Constants.defaultConnectionRetryAttempts,
connectionHost: this._context.namespace.config.host,
delayInSeconds: 15
};
return retry(config);
});
}