Reputation: 111
I have a need for running queued jobs sequentially (or with n threads in parallel) in the background to better control load on the system.
The jobs will be queued in an SQL Server 2008 database using a table as the queue.
I need a simple "engine" that will deque elements from the queue and execute some processing code. The processing code will be C#/.net.
My primary concerns are simplicity, testability, simple deployment and reliabilty.
I am looking for recommendations on the technology, like Biztalk or maybe a Windows Service?
Upvotes: 0
Views: 149
Reputation: 294297
What kind of jobs are we talking about? If the jobs themselves consist from database work, then your best option is to leverage internal Activation in SQL Server. Internal activation can launch C#/.Net code too. See Asynchronous procedure execution for an example. Using Activation is the most reliable way. The scheduled jobs can survive mirroring and clustering fail over. In fact is so reliable that the scheduled job will activate and run even after a server crash and rebuild of the server from database backups on a new host. However, this should not be used if the jobs need to do 'external' work, eg. connect to a Web service. For such services you could use the External Activator and leverage the reliability and self balancing scale inherent on SQL Server Activation mechanism, but ultimately is still a Windows Service and a Service Broker queue.
If you find the overhead of built-in SQL queues to high, I recommend going over Using tables as Queues and try to stick with the basics. Don't add fancy peeks or scans over the queue table, or your system will be swamped by deadlocks, a common issue with using tables as queues.
Upvotes: 0
Reputation: 86882
Here are some options for you but Writing a windows service is the one I would pick. Check the link out. It give a basic example and can help you get started.
Another option would be to use SQL Server Agent as a scheduler to fire off C# executables when needed. However this is not a great option as it feels more like a hack to me.
Upvotes: 1