chilts / mongodb-queue

Message queues which uses MongoDB.
209 stars 91 forks source link

Update with MongoDb API 2.0 #5

Closed hanwencheng closed 8 years ago

hanwencheng commented 9 years ago

Hi, Andy

As node.js mongoDB driver API already update to version 2.0, I update the library

aad6b70 : update the mongodb API functions, detail information is in the commitment, 73422d6 : update readMe.md, and mongoDB version in package.json, c60f4e9 : update the test/indexs.js

I am not sure which version number you want to specify, so I didn't change the version.

This library fit very well for my project, except that I need to clean the acknowledged message, so I am thinking to change the it a little bit, maybe offer an option when creating the queue? How do you think about it?

thanks again for the library !

Hanwen

chilts commented 9 years ago

Hi @hanwencheng - thanks for this, I'll look at it soon.

On the subject of cleaning out the old messages, take a look at the .clean() method. This should already do what you want. I guess you could setInterval it, or just call it after you've processed every x messages. We made it so that it wasn't configured but instead you just called it when you wanted to. :)

hanwencheng commented 9 years ago

Hi, Andy,

It's my fault I didn't make it clear, by clean I mean totally delete. Saving into database and check it periodically is good for monitor and further processing, now I am using it in an optional way which is directly delete it after acknowledge it, that fit my scenario well and consume less cpu caused by querying and setInterval function. so instead using findOneAndUpdate() in ack(), I use deleteOne(), and only the size() and inFlight() now make sense.

chilts commented 9 years ago

Ah yeah, ok, cool. Perhaps I should add the option to delete rather than just update each message and just say 'deleted'. :)

HCanber commented 9 years ago

@chilts Any plans to merge this and release a new npm package?

johnculviner commented 8 years ago

:+1: as the tests pass please click merge

johnculviner commented 8 years ago

Actually maybe bump version to v2 to avoid any breaking issues for people doing the infamous carrot ^

chilts commented 8 years ago

I haven't looked over this but I am failing at doing so.

Am happy to merge.

Also, wouldn't any of you like commit rights to this repo and release rights to npm? I'll quite happily add you all.

chilts commented 8 years ago

Published as v2.0.0 to npm. Thanks guys.

johnculviner commented 8 years ago

Hey thanks for merging this and thanks for building it! Comes in handy when I already got a nice replicated mongo going and don't want to mess w/ building out a Rabbit cluster for something light. I'll let you know if I end up coming across any other features and you can add me then. Thanks again!

chilts commented 8 years ago

No problems. Glad you like the project.