aws-sqs-connector
Amazon WebService SQS Connector
Last updated 5 years ago by elgubenis .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install aws-sqs-connector 
SYNC missed versions from official npm registry.

AWS SQS Connector

Tired of all the hassles connecting and polling a Amazon WebService SQS? The solution is here!

Install

npm install --save aws-sqs-connector

Initialize Queue

With CoffeeScript

SQSConnector = require 'aws-sqs-connector'

Queue = new SQSConnector
  credentials: './credentials/aws.json'
  queueUrl: 'http://sqs.<REGION>.amazonaws.com/<NUMBER>/queue-name'

With JavaScript

var SQSConnector = require('aws-sqs-connector');

var Queue = new SQSConnector({
  credentials: './credentials/aws.json',
  queueUrl: 'http://sqs.<REGION>.amazonaws.com/<NUMBER>/queue-name'
});

Poll Queue

With CoffeeScript

# Everytime there is a new message, this callback gets executed
Queue.receive (message, fetchNext) ->

  # log message
  console.log message

  # log attributes
  console.log message.attributes

  # do some processing with the message and then fetch the next message
  fetchNext()

With JavaScript

Queue.receive(function(message, fetchNext) {
  console.log(message);
  console.log(messages.attributes);
  fetchNext();
});

Send Message

send MessageBody, MessageAttributes, Callback

With CoffeeScript

Queue.send 'message body', { responseRequired: true, randomNumber: 1 }, (err, response) ->
  console.error(err) if err
  console.log response

With JavaScript

Queue.send('message body', { responseRequired: true, randomNumber: 1 }, function(err, response) {
  if (err) { console.error(err); }
  console.log(response);
});

Options

  • Credentials: The credentials json should be of the following format:
{
  "accessKeyId": "YOUR_ACCESS_KEY_ID",
  "secretAccessKey": "YOUR_SECRET_ACCESS_KEY",
  "region": "YOUR_REGION"
}

Current Tags

  • 0.0.9                                ...           latest (5 years ago)

9 Versions

  • 0.0.9                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 4
Dependencies (2)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |