2011年11月2日 星期三

[RabbitMQ] priority queue

目前RabbitMQ沒有直接支援priority queue的功能, 所以目前只能work around, 可以在client動點手腳

建立logical queue, 並根據priority的數量, 來建立physical queue (ex: 如果只有high & low priority, 那就建立兩個queue)

方法一
client polling, 按照priority從相對應的physical queue取出message

方法二
client subsribe queue, 並且限制channel prefetch counts, 防止subscription flood, 並且在local建立in memory priority queue, 直到message被處理, 在送ack給RabbitMQ server 

Reference
http://dougbarth.github.com/2011/07/01/approximating-priority-with-rabbitmq.html 
http://dougbarth.github.com/2011/06/10/keeping-the-rabbit-on-a-leash.html 

沒有留言:

張貼留言