Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Service Broker vs Custom Queue

I am creating a mass mailer application, where a web application sets up a email template and then queues a bunch of email address for sending. The other side will be a Windows service (or exe) that will poll this queue, picking up the messages for sending.

My question is, what would the advantage be of using SQL Service Broker (or MSMQ) over just creating my own custom queue table?

Everything I'm reading is suggesting I use Service Broker, but I really don't see what the huge advantage over a flat table (that would be a lot simpler to work with for me). For reference the application will be used to send 50,000-100,000 emails almost daily.

like image 268
Luke Avatar asked Sep 24 '09 10:09

Luke


1 Answers

Do you know how to implement a queue over a flat table? This is not a silly question, implementing a queue over a table correctly is much harder than it sounds. Queue-like-tables are notoriously deadlock prone and you need to carefully consider the table design and the enqueue and dequeue operations. Also, do you know how to scale your pooling of the table? And how are you goind to handle retries and timeouts (ie. what timers are used for)?

I'm not saying you should use SSB. The lerning curve is very steep and is primarily a distributed applicaiton platform, not a local queueing product so some features, like dialogs, will actually be obstacles for you rather than advantages. I'm just saying that you must consider also the difficulties of flat-table-queues. If you never implemented a flat-table-queue then be warned, there are many dragons under that bridge.

50k-100k messages per day is nothing, is only one message per second. If you want 100k per minute, then we have something to talk about.

like image 108
Remus Rusanu Avatar answered Sep 19 '22 09:09

Remus Rusanu