1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWSにSQSメッセージ送信

Posted at

// Load the SDK for JavaScript
var AWS = require('aws-sdk');

//コンフィグの読み込み
var ini = require('./config/config.json');

var REGION = ini.sqs.test.region;
var SQS_QUEUE_URL = ini.sqs.test.url;
var SQS_ACCESS_KEY_ID = ini.sqs.test.accessKeyId;
var SQS_SECRET_ACCESS_KEY = ini.sqs.test.secretAccessKey;

console.log("▼▼▼ get setting information start ▼▼▼");
console.log(SQS_QUEUE_URL);
console.log(SQS_ACCESS_KEY_ID);
console.log(SQS_SECRET_ACCESS_KEY);
console.log("▲▲▲ get setting information end ▲▲▲");

// Set the config
AWS.config.update(
{
accessKeyId: SQS_ACCESS_KEY_ID,
secretAccessKey: SQS_SECRET_ACCESS_KEY,
region: REGION

}

);

// Create an SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});

var params = {
MessageAttributes: {
"Title": {
DataType: "String",
StringValue: "The Whistler"
},
"Author": {
DataType: "String",
StringValue: "John Grisham"
},
"WeeksOn": {
DataType: "Number",
StringValue: "6"
}
},
MessageBody: "Information about current NY Times fiction bestseller for week of 12/11/2016.",
QueueUrl: SQS_QUEUE_URL,
MessageGroupId: '20180608'
};

sqs.sendMessage(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.MessageId);
}
});

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?