I've a WCF service which pushes the incoming SOAP message from the Third Party to the Azure Storage Queue.
The Third Party system is an automated system which fires the SOAP request messages in BULK. As soon the message is received in WCF, the WCF service reads the message and pushes it to the Azure Storage Queue, which then is read by an Azure Web Job configured using [QueueTrigger] attribute.
public async Task UpdateRatesAsync([QueueTrigger("queue-name")] string message, TextWriter log)
The role of this function is update the Rates of the Product in the system. The web job is triggered as soon as there's a message in the queue and it starts processing the request. When multiple rate messages for the same product are pushed, the QueueTrigger function executes which tries to update the Rates for the same Product at the same time resulting in a race condition.
- How can I resolve this race condition? Is it by reading the message from the queue one by one?
- Do I need to try a different operation to read the message from the queue by removing the QueueTrigger?
config.Queues.MaxDequeueCount = 0;
, so if the job fails the message gets placed in a different "poison" queue, which can be handled differently. – A.J Alhorr