10
votes

I have a queue in Azure storage named for example 'messages'. And every 1 hour some service push to this queue some amount of messages that should update data. But, in some cases I also push to this queue message from another place and I want this message be proceeded immediately and I can not set priority for this message.

What is the best solution for this problem? Can I use two different queues ('messages' and 'messages-priority') or it is a bad approach?

1
With Windows Azure Queues, you can't set the priority message so there your only option would be to use 2 separate queues. May I suggest you take a look at Windows Azure Service Bus Queues? I haven't used it personally but I believe it is more feature rich than Windows Azure Queues.Gaurav Mantri
I haven't used Windows Azure Service Bus Queues too, but will try to investigate it.bogdan

1 Answers

9
votes

The correct approach is to use multiple queues - a 'normal priority' and a 'high priority' queue. What we have implemented is multiple queue reader threads in a single worker role - each thread first checks the high priority queue and, if its empty, looks in the normal queue. This way the high priority messages will be processed by the first available thread (pretty much immediately), and the same code runs regardless of where messages come from. It also saves having to have a reader continuously looking in a single queue and having to be backed off because there are seldom messages.