简体   繁体   中英

How can I call elasticmq on node.js via AWS SDK?

I am developing a node.js project plannig to run on AWS and use Amazon SQS. I am setting up a local development environment using elasticMQ. ( https://github.com/adamw/elasticmq ) It's cool that the binary is also available through npm.

Is it possible to use AWS SDK for Javascript to make calls to the local sqs-like process? Or must I go via REST interface? Can someone share a code sample for initializing calls to elasticmq?

Many thanks!

OK I found it: ) posting here as it may help someone:

var AWS = require('aws-sdk\\global');
var SQS = require('aws-sdk\\clients\\SQS');


var myCredentials = new AWS.Credentials("x", "x");

var sqs = new AWS.SQS({
    apiVersion: '2012-11-05', 
    credentials: myCredentials,
    region: "none",
    endpoint: "http://localhost:9324"
});

var params = {};

//sample code from amazon
console.log("calling listQueues");
//call for SQS list
sqs.listQueues(params, function (err, data) {
    if (err) {
        console.log("Error", err);
    } else {
        console.log("Success", data.QueueUrls);
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM