Skip to content

Commit

Permalink
Merge pull request #98 from lumigo-io/feature/sqs_attribute_not_suppo…
Browse files Browse the repository at this point in the history
…rted

fix: handle message attributes
  • Loading branch information
theburningmonk authored Jun 5, 2020
2 parents adbf458 + bc87e13 commit 0ecea22
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/commands/replay-sqs-dlq.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,25 @@ class ReplaySqsDlqCommand extends Command {
const SQS = new AWS.SQS();

return async messages => {
const sendEntries = messages.map(msg => ({
Id: msg.MessageId,
MessageBody: msg.Body,
MessageAttributes: msg.MessageAttributes
}));
const sendEntries = messages.map(msg => {
// as per #94, can't send message attributes where StringListValues is defined...
const msgAttrPairs = _.toPairs(msg.MessageAttributes);
const supportedAttrs = msgAttrPairs
// eslint-disable-next-line no-unused-vars
.filter(([key, value]) => value.DataType === "String")
.map(([key, { DataType, StringValue }]) => [
key,
{ DataType, StringValue }
]);
const messageAttributes = _.fromPairs(supportedAttrs);

return {
Id: msg.MessageId,
MessageBody: msg.Body,
MessageAttributes: messageAttributes
};
});

await SQS.sendMessageBatch({
QueueUrl: queueUrl,
Entries: sendEntries
Expand Down

0 comments on commit 0ecea22

Please sign in to comment.