NoSQL Message Queue Document Databases – Using NoSQL Document Database as a Message Queue

document-databasesmessage-queuenosql

I am considering using a NoSQL Document database as a messaging queue.

Here is why:

  • I want a client to post a message (some serialized object) to the server and not have to wait for a synchronous response.
  • I want to be able to pull messages off of the "queue" based on some criteria, which may be more sophisticated than just a priority level (I am working on a hosted web app, so I want to give all of my customers a fair amount of "computing time", and not let one customer hog all of the processing).
  • I want the queue to be durable – if the server goes down I want any remaining messages to be handled when it comes back up.

So, I am considering using MongoDB or RavenDB as a message queue. The client can post the message object to a web service which writes it to the database. Then – the service doing the work can pull the various message types based on any criteria that may arise. I can create indexes around the scenarios to make it faster.

So – I am looking for someone to shoot a hole in this. Has anybody successfully done this? Has anybody tried this and failed in some way?

Best Answer

Check out the accepted answer on this question: https://stackoverflow.com/questions/4745911/nosql-databases

My take on having worked with both types of databases is that the real advantages of NoSQL lie in their scalability. They are well suited for ever-growing blobs of stuff that needs to exist on many nodes. After all, these are the applications that they were born out of (Facebook, Google...).

They have downsides also, and they are specific to implementation. Personally, I've suffered with some replication errors when multiple nodes would delete and re-populate objects within a short amount of time. I'm not necessarily suggesting that it is always pervasive, but the speed advantage often comes with less guarantees of consistency (ie, you will have eventual consistency, but you don't want to depend on it).

If all you're doing is building a queue, then I don't see anything specific to NoSQL that makes them a preferred choice. The speed/reliability/efficiency of it will come down more to the configuration of whatever implementation it is that you decide to go with.

Related Topic