I have Gigabytes of data (stored in messages, each message is about 500KB) in a cloud queue (Azure) and data keeps coming.
I need to do some processing on each message. I've decided to create 2 background workers, one to get the data into memory, and the other to process that data:
GetMessage(CloudQueue cloudQueue, LocalQueue localQueue)
{
lock (localQueue)
{
localQueue.Enqueue(cloudQueue.Dequeue());
}
}
ProcessMessage(LocalQueue localQueue)
{
lock (localQueue)
{
Process(localQueue.Dequeue());
}
}
The issue is that data never stops coming so I'll be spending ALOT of time on synchronizing the local queue. Is there a known pattern for this type of problem?