Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 927
Eye of the Storm Avatar asked Jan 04 '23 02:01

Eye of the Storm


1 Answers

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);
    }
});
like image 172
Eye of the Storm Avatar answered Jan 13 '23 15:01

Eye of the Storm