Code Monkey home page Code Monkey logo

sqs-queue-parallel's People

Contributors

bigluck avatar chriskinsman avatar sdossick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sqs-queue-parallel's Issues

Add stopping capability

Currently, there's no way to stop listening. AWS.Request exposes an abort() that can be used to stop the queue. I'd make a pull request, but I don't drink Coffee.

Maybe store active requests returned from self.client.receiveMessage, and expose a disconnect() method on the queue?

Btw, love your use of the async module. i don't leave home without it.

Memory Leak

Running the following reduced test case will cause the node process to balloon it's memory usage, especially if it's processing messages. If it's just waiting for new messages, the process still see memory usage increases.

var SqsQueueParallel = require('sqs-queue-parallel');

var queue = new SqsQueueParallel({
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  name: process.env.INCOMING_QUEUE_NAME,
  region: process.env.AWS_QUEUE_REGION,
  debug: process.env.DEBUG
});

queue.on("message", function(m) {
  m.deleteMessage(function(err) {
    if ( err ) {
      console.log("Error deleting message:\n%s", err.stack);
    }

    m.next();
  });
});

listQueues is used where getQueueURL would be sufficient

It appears this library uses sqs.listQueues and some convoluted regexp matching in order to discover the QueueUrl it is supposed to use.

The AWS API and SDK provide a sqs.getQueueUrl method, which accepts a queue name and returns the QueueUrl. No need to provide permissions to list all queues on the account, regexp match urls whose formats are not guaranteed, or discard QueueUrls for queues that happen to begin with the name you give but don't match.

If this project still alive?

I need something like this, but see a lot of open issues and not merged pull request...
Is this still a thing?

deleteMessage() calls next() before deleting message

This can cause the deleteMessage to get scheduled to be called after the visibility window has expired for each message.

next() should be called after deleteMessage() or not at all so it can be called in the callback for delete message

Correct approach for calling next in on('message')

If I have long running work that I want to process in response to a message coming in from on('message'), what is the best practice for calling next()?

I have my max messages set to 10, and concurrency set to 1. In my simple tests though, it seems that it is only processing one message at a time until I call next().

The part of the documentation that is confusing me is this:
For example, 2 concurrency queue with 5 maxNumberOfMessages can trigger a max of 5 * 2 = 10 message events; so it's very important to be carefull, expecially if you're working with I/O streams.

My understanding of this would then be, if I have max messages set to 10, and concurrency to 1, that I should be getting on('message') called ten times in quick succession, however, the next on('message') event isn't being fired until the previous one calls next(). Is this expected? Is the documentation just misleading?

Line 48 is an issue

you need
try JSON.parse(message.Body) catch then message.Body

try {
JSON.parse(message.Body);
} catch (_error) {
message.Body;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.