[原创]AMQP-RabbitMQ/4/路由模式

简介: [原创]AMQP-RabbitMQ/4/路由模式

4. 路由模式 Routing



  • 图示


image.png


# 个人理解


  • 生产者定义Exchange,设置类型为direct。将消息发送给Exchange之前,为每条消息指定路由键
  • 消费者定义队列Queue,并将队列与Exchange进行绑定,在绑定的时候需要告诉Exchange,当前这个Queue接受的路由键。
  • 消息由Exchange发送给Queue时,消息的routingKey必须与该队列订阅的routingKey完全匹配
  • 即:相对于Exchange为fanout模式的全量接受,direct模式只是根据路由键部分接收Exchange中的消息
  • 生产者

package com.futao.springmvcdemo.mq.rabbit.routing;
import com.futao.springmvcdemo.mq.rabbit.ExchangeTypeEnum;
import com.futao.springmvcdemo.mq.rabbit.RabbitMqConnectionTools;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import lombok.Cleanup;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
/**
 * 路由模式-生产者
 *
 * @author futao
 * Created on 2019-04-22.
 */
@Slf4j
public class Producer {
    @SneakyThrows
    public static void main(String[] args) {
        @Cleanup
        Connection connection = RabbitMqConnectionTools.getConnection();
        @Cleanup
        Channel channel = connection.createChannel();
        //定义交换器类型
        channel.exchangeDeclare(ExchangeTypeEnum.DIRECT.getExchangeName(), BuiltinExchangeType.DIRECT);
        String msg = "Hello RabbitMq!";
      //向名为为`myExchangeType-direct`,类型为`direct`的Exchange发送20条routingKey为`log.info`的消息
        for (int i = 0; i < 20; i++) {
            channel.basicPublish(ExchangeTypeEnum.DIRECT.getExchangeName(), "log.info", null, (msg + i + "log.info").getBytes());
            log.info("Send msg:[{}] ,routingKey:[{}] success", (msg + i + "log.info"), "log.info");
        }
 //向名为为`myExchangeType-direct`,类型为`direct`的Exchange发送20条routingKey为`log.error`的消息
        for (int i = 0; i < 10; i++) {
            channel.basicPublish(ExchangeTypeEnum.DIRECT.getExchangeName(), "log.error", null, (msg + i + "log.error").getBytes());
            log.info("Send msg:[{}] ,routingKey:[{}] success", (msg + i + "log.error"), "log.error");
        }
    }
}
  • 消费者1(同时订阅路由key为"log.info"和"log.error"的消息)

package com.futao.springmvcdemo.mq.rabbit.routing;
import com.futao.springmvcdemo.mq.rabbit.ExchangeTypeEnum;
import com.futao.springmvcdemo.mq.rabbit.RabbitMqConnectionTools;
import com.futao.springmvcdemo.mq.rabbit.RabbitMqQueueEnum;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
/**
 * 路由模式-消费者1
 *
 * @author futao
 * Created on 2019-04-22.
 */
@Slf4j
public class ConsumerOne {
    @SneakyThrows
    public static void main(String[] args) {
        Channel channel = RabbitMqConnectionTools.getChannel();
        //开启持久化队列
        boolean durable = true;
        channel.queueDeclare(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_ONE.getQueueName(), durable, false, false, null);
        //定义交换器类型
        channel.exchangeDeclare(ExchangeTypeEnum.DIRECT.getExchangeName(), BuiltinExchangeType.DIRECT);
        //将消息队列与Exchange交换器与路由键绑定(同时订阅路由key为"log.info"和"log.error"的消息)
        channel.queueBind(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_ONE.getQueueName(), ExchangeTypeEnum.DIRECT.getExchangeName(), "log.error");
        channel.queueBind(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_ONE.getQueueName(), ExchangeTypeEnum.DIRECT.getExchangeName(), "log.info");
        //告诉rabbitmq一次只发送一条消息,并且在前一个消息未被处理或者消费之前,不继续发送下一个消息
        channel.basicQos(1);
        log.info("Waiting for message...");
        DeliverCallback deliverCallback = ((consumerTag, message) -> {
            log.info("收到消息:[{}],routingKey:[{}],tag:[{}]", new String(message.getBody()), message.getEnvelope().getRoutingKey(), consumerTag);
            //acknowledgment应答
            channel.basicAck(message.getEnvelope().getDeliveryTag(), false);
            try {
                Thread.sleep(1000);
            } catch (Exception e) {
            }
        });
        //关闭自动应答
        boolean autoAck = false;
        channel.basicConsume(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_ONE.getQueueName(), autoAck, deliverCallback, consumerTag -> {
        });
    }
}
  • 消费者2(只订阅路由key为"log.error"的消息)

package com.futao.springmvcdemo.mq.rabbit.routing;
import com.futao.springmvcdemo.mq.rabbit.ExchangeTypeEnum;
import com.futao.springmvcdemo.mq.rabbit.RabbitMqConnectionTools;
import com.futao.springmvcdemo.mq.rabbit.RabbitMqQueueEnum;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
/**
 * 路由模式-消费者2
 *
 * @author futao
 * Created on 2019-04-22.
 */
@Slf4j
public class ConsumerTwo {
    @SneakyThrows
    public static void main(String[] args) {
        Channel channel = RabbitMqConnectionTools.getChannel();
        //开启持久化队列
        boolean durable = true;
        channel.queueDeclare(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_TWO.getQueueName(), durable, false, false, null);
        //定义交换器类型
        channel.exchangeDeclare(ExchangeTypeEnum.DIRECT.getExchangeName(), BuiltinExchangeType.DIRECT);
        //将消息队列与Exchange交换器进行绑定(只订阅路由key为"log.error"的消息)
        channel.queueBind(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_TWO.getQueueName(), ExchangeTypeEnum.DIRECT.getExchangeName(), "log.error");
        //告诉rabbitmq一次只发送一条消息,并且在前一个消息未被处理或者消费之前,不继续发送下一个消息
        channel.basicQos(1);
        log.info("Waiting for message...");
        DeliverCallback deliverCallback = ((consumerTag, message) -> {
            log.info("收到消息:[{}],routingKey:[{}],tag:[{}]", new String(message.getBody()), message.getEnvelope().getRoutingKey(), consumerTag);
            //acknowledgment应答
            channel.basicAck(message.getEnvelope().getDeliveryTag(), false);
            try {
                Thread.sleep(2000);
            } catch (Exception e) {
            }
        });
        //关闭自动应答
        boolean autoAck = false;
        channel.basicConsume(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_TWO.getQueueName(), autoAck, deliverCallback, consumerTag -> {
        });
    }
}
  • 测试

>>> 生产者
17:35:22.151 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!0log.info] ,routingKey:[log.info] success
17:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!1log.info] ,routingKey:[log.info] success
17:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!2log.info] ,routingKey:[log.info] success
17:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!3log.info] ,routingKey:[log.info] success
17:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!4log.info] ,routingKey:[log.info] success
17:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!5log.info] ,routingKey:[log.info] success
17:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!6log.info] ,routingKey:[log.info] success
17:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!7log.info] ,routingKey:[log.info] success
17:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!8log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!9log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!10log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!11log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!12log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!13log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!14log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!15log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!16log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!17log.info] ,routingKey:[log.info] success
17:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!18log.info] ,routingKey:[log.info] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!19log.info] ,routingKey:[log.info] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!0log.error] ,routingKey:[log.error] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!1log.error] ,routingKey:[log.error] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!2log.error] ,routingKey:[log.error] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!3log.error] ,routingKey:[log.error] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!4log.error] ,routingKey:[log.error] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!5log.error] ,routingKey:[log.error] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!6log.error] ,routingKey:[log.error] success
17:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!7log.error] ,routingKey:[log.error] success
17:35:22.159 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!8log.error] ,routingKey:[log.error] success
17:35:22.159 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!9log.error] ,routingKey:[log.error] success
Disconnected from the target VM, address: '127.0.0.1:58582', transport: 'socket'
> 消费者1-同时订阅了路由键为`log.info`和`log.error`的消息
17:35:15.737 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - Waiting for message...
17:35:22.153 [pool-1-thread-4] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!0log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:23.157 [pool-1-thread-5] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!1log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:24.162 [pool-1-thread-6] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!2log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:25.167 [pool-1-thread-7] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!3log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:26.173 [pool-1-thread-8] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!4log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:27.176 [pool-1-thread-9] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!5log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:28.179 [pool-1-thread-10] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!6log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:29.184 [pool-1-thread-11] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!7log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:30.190 [pool-1-thread-12] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!8log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:31.191 [pool-1-thread-13] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!9log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:32.195 [pool-1-thread-14] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!10log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:33.201 [pool-1-thread-15] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!11log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:34.203 [pool-1-thread-16] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!12log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:35.208 [pool-1-thread-17] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!13log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:36.211 [pool-1-thread-18] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!14log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:37.215 [pool-1-thread-19] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!15log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:38.222 [pool-1-thread-20] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!16log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:39.226 [pool-1-thread-21] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!17log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:40.229 [pool-1-thread-22] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!18log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:41.233 [pool-1-thread-23] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!19log.info],routingKey:[log.info],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:42.239 [pool-1-thread-24] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!0log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:43.243 [pool-1-thread-25] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!1log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:44.248 [pool-1-thread-26] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!2log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:45.253 [pool-1-thread-26] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!3log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:46.258 [pool-1-thread-26] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!4log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:47.259 [pool-1-thread-26] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!5log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:48.259 [pool-1-thread-26] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!6log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:49.261 [pool-1-thread-26] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!7log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:50.262 [pool-1-thread-26] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!8log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
17:35:51.262 [pool-1-thread-9] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - 收到消息:[Hello RabbitMq!9log.error],routingKey:[log.error],tag:[amq.ctag-69-YK4fbdRWsRxpVYI280A]
> 消费者2-只订阅了路由键为`log.error`的消息
17:35:18.722 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - Waiting for message...
17:35:22.161 [pool-1-thread-4] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!0log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:24.164 [pool-1-thread-5] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!1log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:26.167 [pool-1-thread-6] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!2log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:28.173 [pool-1-thread-7] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!3log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:30.179 [pool-1-thread-8] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!4log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:32.184 [pool-1-thread-9] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!5log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:34.189 [pool-1-thread-10] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!6log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:36.191 [pool-1-thread-11] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!7log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:38.192 [pool-1-thread-12] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!8log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]
17:35:40.195 [pool-1-thread-13] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - 收到消息:[Hello RabbitMq!9log.error],routingKey:[log.error],tag:[amq.ctag-IkbrVC8PYMJLwVuD8k6vSg]


相关实践学习
RocketMQ一站式入门使用
从源码编译、部署broker、部署namesrv,使用java客户端首发消息等一站式入门RocketMQ。
消息队列 MNS 入门课程
1、消息队列MNS简介 本节课介绍消息队列的MNS的基础概念 2、消息队列MNS特性 本节课介绍消息队列的MNS的主要特性 3、MNS的最佳实践及场景应用 本节课介绍消息队列的MNS的最佳实践及场景应用案例 4、手把手系列:消息队列MNS实操讲 本节课介绍消息队列的MNS的实际操作演示 5、动手实验:基于MNS,0基础轻松构建 Web Client 本节课带您一起基于MNS,0基础轻松构建 Web Client
相关文章
|
6月前
|
消息中间件 存储 负载均衡
Rabbitmq direct模式保证一个队列只对应一个消费者
Rabbitmq direct模式保证一个队列只对应一个消费者
112 0
|
6月前
|
消息中间件 存储 网络协议
我们一起来学RabbitMQ 二:RabbiMQ 的 6 种模式的基本应用
我们一起来学RabbitMQ 二:RabbiMQ 的 6 种模式的基本应用
|
5月前
|
Java Maven
SpringBoot集成RabbitMQ-三种模式的实现
SpringBoot集成RabbitMQ-三种模式的实现
93 0
|
4月前
|
物联网 Go 网络性能优化
使用Go语言(Golang)可以实现MQTT协议的点对点(P2P)消息发送。MQTT协议本身支持多种消息收发模式
使用Go语言(Golang)可以实现MQTT协议的点对点(P2P)消息发送。MQTT协议本身支持多种消息收发模式【1月更文挑战第21天】【1月更文挑战第104篇】
112 1
|
4月前
|
消息中间件 Java
Java操作RabbitMQ单一生产-消费者模式
Java操作RabbitMQ单一生产-消费者模式
32 0
|
4月前
|
消息中间件 存储 数据安全/隐私保护
深入学习RabbitMQ五种模式(一)
深入学习RabbitMQ五种模式(一)
40 0
|
2月前
|
消息中间件 Java 调度
【深度挖掘RocketMQ底层源码】「底层源码挖掘系列」透彻剖析贯穿RocketMQ的消费者端的运行调度的流程(Pull模式)
【深度挖掘RocketMQ底层源码】「底层源码挖掘系列」透彻剖析贯穿RocketMQ的消费者端的运行调度的流程(Pull模式)
12 1
|
2月前
|
消息中间件 Java RocketMQ
【深度挖掘 RocketMQ底层源码】「底层源码挖掘系列」抽丝剥茧贯穿RocketMQ的消费者端的运行核心的流程(Pull模式-下)
【深度挖掘 RocketMQ底层源码】「底层源码挖掘系列」抽丝剥茧贯穿RocketMQ的消费者端的运行核心的流程(Pull模式-下)
12 1
|
2月前
|
消息中间件 存储 NoSQL
【深度挖掘 RocketMQ底层源码】「底层源码挖掘系列」透彻剖析贯穿RocketMQ的消费者端的运行核心的流程(Pull模式-上)
【深度挖掘 RocketMQ底层源码】「底层源码挖掘系列」透彻剖析贯穿RocketMQ的消费者端的运行核心的流程(Pull模式-上)
27 1
|
5月前
|
消息中间件 中间件 Kafka
RocketMQ源码(二)消息消费的模式到底是Push还是Pull?
RocketMQ源码(二)消息消费的模式到底是Push还是Pull?
83 1