'Multiple micro service or console application that read from a single table
I need to read millions of records from a sqlserver table through a microservice that does block reads in parallel. each instantiated microservice performs the same read operation on the same table of the same DB. what is the best approach you can use to avoid taking duplicate records? By duplicate records I mean not to process / collect records that have already been collected / processed by other instances of the same service
Can I use this approach? make selections from each microservice such as the following:
BEGIN TRANSACTION;
SELECT ITEM_ID
FROM TABLE_ITEM
WITH(XLOCK, ROWLOCK)
WHERE ITEM_PRIORITY > 10 AND ITEM_CATEGORY = 'CT1' AND ITEM_STATUS = 'available' AND ROWNUM = 1;
UPDATE [locked item_id] SET ITEM_STATUS = 'unavailable';
COMMIT TRANSACTION;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
