Created
March 21, 2023 20:21
-
-
Save uzair004/ac82e5f5c9ea4e87e0d1a0380721e840 to your computer and use it in GitHub Desktop.
push to sqs queue using nodejs
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
const AWS = require("aws-sdk"); | |
// api key etc will be take from .env | |
AWS.config.update({ region: process.env.AWS_REGION }); | |
const sqs = new AWS.SQS({ apiVersion: "2012-11-05" }); | |
const pushToQueue = (message) => { | |
return new Promise((resolve, reject) => { | |
sqs.sendMessage( | |
{ | |
MessageBody: JSON.stringify(message), | |
QueueUrl: process.env.RES_QUEUE_ENDPOINT, | |
}, | |
function (err, data) { | |
if (err) reject(err); | |
else if (data) resolve(data); | |
} | |
); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment