Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (msg.timeToLive != null && msg.timeToLive !== Constants.maxDurationValue) {
amqpMsg.ttl = msg.timeToLive;
amqpMsg.creation_time = Date.now();
if (Constants.maxAbsoluteExpiryTime - amqpMsg.creation_time > amqpMsg.ttl) {
amqpMsg.absolute_expiry_time = amqpMsg.creation_time + amqpMsg.ttl;
} else {
amqpMsg.absolute_expiry_time = Constants.maxAbsoluteExpiryTime;
}
}
if (msg.partitionKey != null) {
if (msg.partitionKey.length > Constants.maxPartitionKeyLength) {
throw new Error(
"Length of 'partitionKey' property on the message cannot be greater than 128 characters."
);
}
amqpMsg.message_annotations![Constants.partitionKey] = msg.partitionKey;
}
if (msg.viaPartitionKey != null) {
if (msg.viaPartitionKey.length > Constants.maxPartitionKeyLength) {
throw new Error(
"Length of 'viaPartitionKey' property on the message cannot be greater than 128 characters."
);
}
amqpMsg.message_annotations![Constants.viaPartitionKey] = msg.viaPartitionKey;
}
if (msg.scheduledEnqueueTimeUtc != null) {
amqpMsg.message_annotations![Constants.scheduledEnqueueTime] = msg.scheduledEnqueueTimeUtc;
}
log.message("SBMessage to AmqpMessage: %O", amqpMsg);
return amqpMsg;
}if (msg.subject != null) {
sbmsg.label = msg.subject;
}
if (msg.message_id != null) {
sbmsg.messageId = msg.message_id;
}
if (msg.correlation_id != null) {
sbmsg.correlationId = msg.correlation_id;
}
if (msg.reply_to_group_id != null) {
sbmsg.replyToSessionId = msg.reply_to_group_id;
}
if (msg.message_annotations != null) {
if (msg.message_annotations[Constants.partitionKey] != null) {
sbmsg.partitionKey = msg.message_annotations[Constants.partitionKey];
}
if (msg.message_annotations[Constants.viaPartitionKey] != null) {
sbmsg.viaPartitionKey = msg.message_annotations[Constants.viaPartitionKey];
}
if (msg.message_annotations[Constants.scheduledEnqueueTime] != null) {
sbmsg.scheduledEnqueueTimeUtc = msg.message_annotations[Constants.scheduledEnqueueTime];
}
}
const props: any = {};
if (msg.message_annotations != null) {
if (msg.message_annotations[Constants.deadLetterSource] != null) {
props.deadLetterSource = msg.message_annotations[Constants.deadLetterSource];
}
if (msg.message_annotations[Constants.enqueueSequenceNumber] != null) {
props.enqueuedSequenceNumber = msg.message_annotations[Constants.enqueueSequenceNumber];if (msg.subject != null) {
sbmsg.label = msg.subject;
}
if (msg.message_id != null) {
sbmsg.messageId = msg.message_id;
}
if (msg.correlation_id != null) {
sbmsg.correlationId = msg.correlation_id;
}
if (msg.reply_to_group_id != null) {
sbmsg.replyToSessionId = msg.reply_to_group_id;
}
if (msg.message_annotations != null) {
if (msg.message_annotations[Constants.partitionKey] != null) {
sbmsg.partitionKey = msg.message_annotations[Constants.partitionKey];
}
if (msg.message_annotations[Constants.viaPartitionKey] != null) {
sbmsg.viaPartitionKey = msg.message_annotations[Constants.viaPartitionKey];
}
if (msg.message_annotations[Constants.scheduledEnqueueTime] != null) {
sbmsg.scheduledEnqueueTimeUtc = msg.message_annotations[Constants.scheduledEnqueueTime];
}
}
const props: any = {};
if (msg.message_annotations != null) {
if (msg.message_annotations[Constants.deadLetterSource] != null) {
props.deadLetterSource = msg.message_annotations[Constants.deadLetterSource];
}
if (msg.message_annotations[Constants.enqueueSequenceNumber] != null) {
props.enqueuedSequenceNumber = msg.message_annotations[Constants.enqueueSequenceNumber];}
if (msg.subject != null) {
sbmsg.label = msg.subject;
}
if (msg.message_id != null) {
sbmsg.messageId = msg.message_id;
}
if (msg.correlation_id != null) {
sbmsg.correlationId = msg.correlation_id;
}
if (msg.reply_to_group_id != null) {
sbmsg.replyToSessionId = msg.reply_to_group_id;
}
if (msg.message_annotations != null) {
if (msg.message_annotations[Constants.partitionKey] != null) {
sbmsg.partitionKey = msg.message_annotations[Constants.partitionKey];
}
if (msg.message_annotations[Constants.viaPartitionKey] != null) {
sbmsg.viaPartitionKey = msg.message_annotations[Constants.viaPartitionKey];
}
if (msg.message_annotations[Constants.scheduledEnqueueTime] != null) {
sbmsg.scheduledEnqueueTimeUtc = msg.message_annotations[Constants.scheduledEnqueueTime];
}
}
const props: any = {};
if (msg.message_annotations != null) {
if (msg.message_annotations[Constants.deadLetterSource] != null) {
props.deadLetterSource = msg.message_annotations[Constants.deadLetterSource];
}
if (msg.message_annotations[Constants.enqueueSequenceNumber] != null) {