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

2.3k views Asked by At

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!

1

There are 1 answers

0
Eye of the Storm On

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);
    }
});