views:

242

answers:

6

Hi,

I am in the process of writing a message queue system.

My question is... Is it better to do this queue with files or in a database?

If I were to choose the database, it needs to check for new jobs every second and that just seems a bit of an overhead to me?

If it's files I guess you just constantly monitor the folder and execute based on that?

BR,

+1  A: 

It depends on your requirements, but if you need to queue up multiple messages as one single group, you'll need some sort of transactional support. In that case the database is your friend.

Steven
+14  A: 
Joel Coehoorn
+1 yes - absolutely! Too bad so few people seem to know about this technology....
marc_s
+1MSMQ with WCF
Arnold Zokas
+1: I know about it but 33 seconds too slow ;-)
Cory Charlton
+1. You're right and MSMQ also has transactional support.
Steven
+9  A: 

Don't reinvent the wheel.

Wyatt Barnett
+4  A: 

How might want to look into MSMQ

Cory Charlton
Since you're not on meta often, I'm commenting here to let you know I responded to your post about this question on meta.
Joel Coehoorn
+1  A: 

Are you writing a message queue system because you want to write a message queue system; or is this just part of solving a bigger problem?

I would suggest not writing a new message queue system. You can use MSMQ or something else off the shelf.

danpaq
+2  A: 

what are your criteria for deciding "Better"? performance? scalability? reliability? cost?

The basic tradeoffs are:

Database - transactional support, integrity guarantees (via constraints), richer query support, probably will scale better (depending on implementation)

filesystem - cheaper, simpler, less moving parts (at least initially)

You may want to look at existing solutions first - MSMQ, SQL Server broker, open source libraries such as Rhino queues (http://ayende.com/Blog/archive/2008/08/01/Rhino-Queues.aspx)

Addys