あなたはaws-sdkライブラリを試しましたか?ここで
https://milesplit.wordpress.com/2013/11/07/using-sqs-with-node/がまとめたものである:ここでは、そこからドキュメントです
var AWS = require('aws-sdk'),
sqsQueueUrl = 'https://sqs.us-east-1.amazonaws.com/123455678/test-queue',
sqs;
// Load credentials from local json file
AWS.config.update({
"accessKeyId": "YOUR AWS PUBLIC KEY",
"secretAccessKey": "YOUR AWS SECRET KEY",
"region": "us-east-1"
});
// Instantiate SQS client
sqs = new AWS.SQS().client;
:あなたは、外部ファイルを使用したくない場合は、
var AWS = require('aws-sdk'),
awsCredentialsPath = './aws.credentials.json',
sqsQueueUrl = 'https://sqs.us-east-1.amazonaws.com/123455678/test-queue',
sqs;
// Load credentials from local json file
AWS.config.loadFromPath(awsCredentialsPath);
// Instantiate SQS client
sqs = new AWS.SQS().client;
をまたは:最初のSQSへの接続その後、メッセージを読んでください:
sqs.receiveMessage({
QueueUrl: sqsQueueUrl,
MaxNumberOfMessages: 1, // how many messages do we wanna retrieve?
VisibilityTimeout: 60, // seconds - how long we want a lock on this job
WaitTimeSeconds: 3 // seconds - how long should we wait for a message?
}, function(err, data) {
// If there are any messages to get
if (data.Messages) {
// Get the first message (should be the only one since we said to only get one above)
var message = data.Messages[0],
body = JSON.parse(message.Body);
// Now this is where you'd do something with this message
doSomethingCool(body, message); // whatever you wanna do
}
});
あまりにも多くの仮定、あまりにも多くの仮定。あなたが話している労働者は何ですか?コードや標準ライブラリを所有していますか? – mootmoot