0.1.6 • Published 9 years ago

sqs-postman v0.1.6

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

sqs-postman

A simple tool for sending messages to AWS SQS

It comes with the following features out of the box:

  • Sends messages in batches of up to 10 messages at a time (AWS limit)
  • Batches are sent out in parallel using a default of 10 producers, which can be configured using the --concurrent-producers option

Installation

$ npm install -g sqs-postman

AWS Configuration

For configuring AWS credentials, please go here.

Usage

$ postman --help

Usage: postman [options] [command]


  Commands:

    message [options] <queue>  Messages the specified queue
    stats <queue>              Gets queue stats

  Options:

    -h, --help                 output usage information
    -V, --version              output the version number
    -p, --aws-profile <value>  Specifies AWS profile name. It defaults to default
    -r, --aws-region <id>      Specifies the AWS region. It defaults to eu-west-1

The help option can be used in commands too $ postman message --help

Examples

Send message to queue using custom AWS profile

$ postman message my-queue --aws-profile my-profile --message-source ./message.json

Send 15 messages to queue using custom profile and specific AWS region

$ postman message my-queue --aws-profile my-profile --aws-region us-east-1 --message-source ./message.json --total 15

Send 1000 messages using 20 concurrent producers

$ postman message my-queue --message-source ./message.json --total 1000 --concurrent-producers 20

API

Postman can also be included on any project and used programmatically.

sendMessage(options, cb)

  • options - an object containing options
    • queueName - the name of the SQS queue
    • messageSource - the path to the file containing the message body, e.g.: ./my-message.json
    • total - the total number of messages that need to be sent out
  • cb(err, result) - a callback which is called when all messages have been sent, or an error occurs

getQueueUrl(queueName, cb)

  • queueName - the name of the SQS queue
  • cb(err, queueUrl) - a callback which is called with either the queueUrl or an error if any

getStats(queueUrl, cb)

  • queueUrl - the queueUrl
  • cb(err, stats) - a callback which is called with either the queue stats or an error if any

Debugging

Postman uses the debug module, and can be enabled as follows:

$ DEBUG=sqs-postman* postman ...

Performance Tests

Messagesaws-clisqs-postman
1000m 4.956s0m 0.90s
10002m 31.457s0m 4.18s
100008m 30.715s0m 30.83s

The difference in performance between aws-cli and sqs-postman is huge! Because of sqs-postman's ability to process batches in parallel (async), the execution time can be reduced quite considerably.

These tests were performed on a Macbook Pro 15-inch, Mid 2012 with a 2.6 GHz Intel Core i7 Processor and 16 GB 1600 MHz DDR3 of RAM. And time was measured using Unix time.

Contributing

Contributions are always welcome! Just follow the normal fork > branch > pull request workflow.

License

MIT

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago