Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure queue message priority

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?

like image 440
bogdan Avatar asked Jan 19 '14 16:01

bogdan


1 Answers

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.

like image 139
Simon Munro Avatar answered Sep 22 '22 17:09

Simon Munro