RabbitMq学习笔记(七)—— 优先级队列

实际业务:

根据客户的不同分类(vip会员和普通用户),vip会员的订单必然要优先处理。涉及到Rabbit的优先级,如果对方订单优先级较高,则优先处理,否则默认处理


优先级队列设置

Map<String,Object> map = new LinkedHashMap<String,Object>();

map.put("x-max-priority", 20);

channel.QueueDeclare(queue: "hello",                               

                                        durable: true, //持久化                                

                                        exclusive: false,   //排外                     

                                        autoDelete: false,                            

                                        arguments: map); //优先级设置


Message中指定优先级属性

channel.CreateBasicProperties().Priority

评论

© dzxlovelar | Powered by LOFTER