@message-queue-toolkit/sqs
Version:
SQS adapter for message-queue-toolkit
17 lines • 781 B
JavaScript
import { isOffloadedPayloadPointerPayload } from '@message-queue-toolkit/core';
export const OFFLOADED_PAYLOAD_SIZE_ATTRIBUTE = 'payloadOffloading.size';
export function resolveOutgoingMessageAttributes(payload) {
const attributes = {};
if (isOffloadedPayloadPointerPayload(payload)) {
attributes[OFFLOADED_PAYLOAD_SIZE_ATTRIBUTE] = {
DataType: 'Number',
// The SQS SDK does not provide properties to set numeric values, we have to convert it to string
StringValue: payload.offloadedPayloadSize.toString(),
};
}
return attributes;
}
export function hasOffloadedPayload(message) {
return !!message.attributes && OFFLOADED_PAYLOAD_SIZE_ATTRIBUTE in message.attributes;
}
//# sourceMappingURL=messageUtils.js.map