Last active
September 7, 2020 06:23
-
-
Save mahiya/9906b5c1aac87c48f66d7f0b451df93c to your computer and use it in GitHub Desktop.
Sample code of calling AWS.SQS.sendMessageBatch method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require('aws-sdk'); | |
var sqs = new AWS.SQS(); | |
const queueUrl = ''; | |
async function sendMessages(messages) { | |
for (var i = 0; i < messages.length;) { | |
var params = { | |
QueueUrl: queueUrl, | |
Entries: [] | |
}; | |
for (var j = 0; j < 10 && i < messages.length; i++ , j++) { | |
params.Entries.push({ | |
Id: i.toString(), | |
MessageBody: messages[i] | |
}); | |
} | |
await sqs.sendMessageBatch(params).promise(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment