Created
March 25, 2021 16:27
-
-
Save oxlb/61f63f27dec05110c597f692eb138c16 to your computer and use it in GitHub Desktop.
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 { SQS, listParams, createParams, msgParams, receiveParam, QUEUE_URL} = require('./util.js'); | |
module.exports = { | |
listSQS: async () => { | |
SQS.listQueues(listParams, function(err, data) { | |
if (err) { | |
console.log("Error", err); | |
} else { | |
console.log("Success", data.QueueUrls); | |
} | |
}); | |
}, | |
createSqsQueue: async () => { | |
SQS.createQueue(createParams, function(err, data) { | |
if (err) { | |
console.log("Error", err); | |
} else { | |
console.log("Success", data.QueueUrl); | |
} | |
}); | |
}, | |
sendMessage: async (msg) => { | |
SQS.sendMessage(msgParams(msg), function(err, data) { | |
if (err) { | |
console.log("Error", err); | |
} else { | |
console.log("Success", data.MessageId); | |
} | |
}); | |
}, | |
getMessage: async () => { | |
SQS.receiveMessage(receiveParam, function(err, data) { | |
if (err) { | |
console.log("Receive Error", err); | |
} else if (data.Messages) { | |
console.log('-----Message------'); | |
console.log(data.Messages); | |
console.log('-----Message End------'); | |
var deleteParams = { | |
QueueUrl: QUEUE_URL, | |
ReceiptHandle: data.Messages[0].ReceiptHandle | |
}; | |
SQS.deleteMessage(deleteParams, function(err, data) { | |
if (err) { | |
console.log("Delete Error", err); | |
} else { | |
console.log("Message Deleted", data); | |
} | |
}); | |
} | |
}); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment