I am deploying an existing bespoke windows service (C#) multiple instances that will reads from a single queue table.
The queue is based on the below simple SQL table.
Record-Id (int auto id)
Added-Date (Date)
Added-By (Text)
Data-To-be-Processed (Text)
**Pool-Number (int)**
How would I create a round robin sequence number for each insert given a max pool size? here I use a pool size of 3 (This can be hard coded). e.g.
1 | 31/10/2014 | DATA | Pool 1
2 | 31/10/2014 | DATA | Pool 2
3 | 31/10/2014 | DATA | Pool 3
4 | 31/10/2014 | DATA | Pool 1
5 | 31/10/2014 | DATA | Pool 2
6 | 31/10/2014 | DATA | Pool 3
7 | 31/10/2014 | DATA | Pool 1
I have thought about using a Sequence table and increment it on each insert and reset it to 1 when it gets to the max pool size e.g.
TbSeq
dbSeq (int) (Will contain 1-3 depending last insert)
Is there a better way to do this?