Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSMQ v Database Table

Tags:

An existing process changes the status field of a booking record in a table, in response to user input.

I have another process to write, that will run asynchronously for records with a particular status. It will read the table record, perform some operations (including calls to third party web services), and update the record's status field to indicate that processing is completed (or In Error, with an error count).

This operation sounds very similar to a queue. What are the benefits and tradeoffs of using MSMQ over a SQL Table in this situation, and why should I choose one over the other?

It is our software that is adding and updating records in the table.

It is a new piece of work (a Windows Service) that will be performing the asynchronous processing. This needs to be "always up".

like image 554
David White Avatar asked Dec 19 '08 03:12

David White


People also ask

Why use MSMQ?

Message Queuing (MSMQ) technology enables applications running at different times to communicate across heterogeneous networks and systems that may be temporarily offline. Applications send messages to queues and read messages from queues.

Does Msmq use SQL?

MSMQ extension changes the way Hangfire handles job queues. Default implementation uses regular SQL Server tables to organize queues, and this extensions uses transactional MSMQ queues to process jobs.


1 Answers

There are several reasons, which were discussed on the Fog Creek forum here: http://discuss.fogcreek.com/joelonsoftware5/default.asp?cmd=show&ixPost=173704&ixReplies=5

The main benefit is that MSMQ can still be used when there is intermittant connectivity between computers (using a store and forward mechanism on the local machine). As far as the application is concerned it delivered the message to MSMQ, even though MSMQ will possibly deliver the message later.

You can only insert a record to a table when you can connect to the database.

A table approach is better when a workflow approach is required, and the process will move through various stages, and these stages need persisting in the DB.

like image 140
Mitch Wheat Avatar answered Oct 11 '22 06:10

Mitch Wheat