Skip to content

Commit

Permalink
Fix SQS consumer - preserve original batch after transform
Browse files Browse the repository at this point in the history
  • Loading branch information
sfount committed Apr 22, 2020
1 parent 09140cf commit b09d381
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/consumers/SQSConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class SQSConsumer implements Consumer {
for (const batch of batches) {
const params: SQS.SendMessageBatchRequest = {
QueueUrl: this.queueUrl,
Entries: batch.map(this.messageBuilder.transform)
Entries: [ ...batch ].map(this.messageBuilder.transform)
}
sqs.sendMessageBatch(params, (error: AWSError, data) => {
if (error) {
Expand All @@ -65,7 +65,8 @@ export default class SQSConsumer implements Consumer {
'batch_id': batchId,
'messages': batch.map((entry, index) => ({
'id': params.Entries[index].Id,
'primary_column': entry[Object.keys(entry)[0]]
'primary_column': entry[Object.keys(entry)[0]],
'body': entry
})),
'failed': data.Failed.map((entry) => ({
'id': entry.Id,
Expand Down

0 comments on commit b09d381

Please sign in to comment.