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

实际业务:

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


优先级队列设置

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

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

channel.QueueDeclare(queue: "hello",      ...

RabbitMq学习笔记(六)—— RPC调用

RpcServer

            //生成Rpc队列

            channel.queueDeclare(RPC_QUEUE_NAME, false, false, false, null);  ...


RabbitMq学习笔记(五)—— Topic

ReceiveTopicOne 匹配规则1

//声明交换器和队列

channel.exchangeDeclare(EXCHANGE_NAME, "topic");

String queueName = channel.queueDeclare().getQueue();

//路由关键字规则

String[] routingKeys = new String[]{"*.*.rabbit", "lazy.#"}; 

//绑定路由关键字

for (String bindingKey : routingKeys...

RabbitMq学习笔记(四)—— 消息路由(Routing)

//声明直连交换器

channel.exchangeDeclare(EXCHANGE_NAME, "direct");  

// 获取匿名队列名称  

String queueName = channel.queueDeclare().getQueue();


根据路由关键字进行多重绑定 

for(String severity :routingKeys){  

        channel.queueBind...

RabbitMq学习笔记(三)—— 交换器(Pub/Topic)

//声明交换器(fanout:分发)rabbitmqctl list_exchanges 查看交换器规则

channel.exchangeDeclare("logs", "fanout");

//创建临时队列

String queueName = channel.queueDeclare().getQueue();

String message = "this is message in the fanout'exchange ";

//发送消息到交换器中

channel.basicPublish...

RabbitMq学习笔记(二)—— 工作队列(WorkQueue)

WorkQueue:有序的处理消息(etc:流水线作业)


消费者消费数据

boolean durable = true;//持久化,保证数据不丢失

channel.queueDeclare("queue_task", durable, false, false, null); 

        //避免负载不均衡,保证一个消费者处理一个消息

        int prefetchCount...

RabbitMq学习笔记(一)—— HelloWorld

Maven:

<!-- rabbitmq -->

<dependency>

  <groupId>com.rabbitmq</groupId>

  <artifactId>amqp-client</artifactId>

  <version>4.0.0</version>

</dependency>

<dependency>

    <groupId>...

Centos6.8安装RabbitMQ

Centos6.8安装RabbitMQ


  1. 安装erlang

    1.1.   安装依赖包

             1.1.1.  yum -y install ncurses-devel

             1.1.2.  yum list | grep ssl     yum install openssl-devel...


© dzxlovelar | Powered by LOFTER