Producer-Consumer-Problem‍ using SQL Server and ASP.NET -


classic producer-consumer-problem.

i have x app servers write records in db table (same db).

on each server, service running polls db table , supposed read oldest entry, process , delete it. issue services race condition: service on server starts reading, server b starts reading same record. i'm bit stuck on this...i have implemented producer-consumer never across server barriers.

the server cannot talk each other except on db.

environment sql server 2005 , asp-net 3.5.

if pick work in transactional way, 1 server can pick up:

set transaction isolation level repeatable read  update  top 1 tbl set     processingonserver = host_name()    yourworktable tbl   processingonserver null         , done = 0 

now can select details, knowing work item safely assigned you:

select  *    yourworktable tbl   processingonserver = host_name()         , done = 0 

the function host_name() returns client name, if think it's safer can pass in hostname client application.

we add timestamp, can check servers took long process item.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -