0°

AMQP-RabbitMQ/4/路由模式

4. 路由模式 Routing

  • 图示

个人理解

  • 生产者定义Exchange,设置类型为direct。将消息发送给Exchange之前,为每条消息指定路由键

  • 消费者定义队列Queue,并将队列与Exchange进行绑定,在绑定的时候需要告诉Exchange,当前这个Queue接受的路由键。

  • 消息由Exchange发送给Queue时,消息的routingKey必须与该队列订阅的routingKey完全匹配

  • 即:相对于Exchange为fanout模式的全量接受,direct模式只是根据路由键部分接收Exchange中的消息

  • 生产者


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
1package com.futao.springmvcdemo.mq.rabbit.routing;
2
3import com.futao.springmvcdemo.mq.rabbit.ExchangeTypeEnum;
4import com.futao.springmvcdemo.mq.rabbit.RabbitMqConnectionTools;
5import com.rabbitmq.client.BuiltinExchangeType;
6import com.rabbitmq.client.Channel;
7import com.rabbitmq.client.Connection;
8import lombok.Cleanup;
9import lombok.SneakyThrows;
10import lombok.extern.slf4j.Slf4j;
11
12/**
13 * 路由模式-生产者
14 *
15 * @author futao
16 * Created on 2019-04-22.
17 */
18@Slf4j
19public class Producer {
20    @SneakyThrows
21    public static void main(String[] args) {
22        @Cleanup
23        Connection connection = RabbitMqConnectionTools.getConnection();
24        @Cleanup
25        Channel channel = connection.createChannel();
26        //定义交换器类型
27        channel.exchangeDeclare(ExchangeTypeEnum.DIRECT.getExchangeName(), BuiltinExchangeType.DIRECT);
28        String msg = "Hello RabbitMq!";
29      //向名为为`myExchangeType-direct`,类型为`direct`的Exchange发送20条routingKey为`log.info`的消息
30        for (int i = 0; i < 20; i++) {
31            channel.basicPublish(ExchangeTypeEnum.DIRECT.getExchangeName(), "log.info", null, (msg + i + "log.info").getBytes());
32            log.info("Send msg:[{}] ,routingKey:[{}] success", (msg + i + "log.info"), "log.info");
33        }
34 //向名为为`myExchangeType-direct`,类型为`direct`的Exchange发送20条routingKey为`log.error`的消息
35        for (int i = 0; i < 10; i++) {
36            channel.basicPublish(ExchangeTypeEnum.DIRECT.getExchangeName(), "log.error", null, (msg + i + "log.error").getBytes());
37            log.info("Send msg:[{}] ,routingKey:[{}] success", (msg + i + "log.error"), "log.error");
38        }
39    }
40}
41
  • 消费者1(同时订阅路由key为"log.info"和"log.error"的消息)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
1package com.futao.springmvcdemo.mq.rabbit.routing;
2
3import com.futao.springmvcdemo.mq.rabbit.ExchangeTypeEnum;
4import com.futao.springmvcdemo.mq.rabbit.RabbitMqConnectionTools;
5import com.futao.springmvcdemo.mq.rabbit.RabbitMqQueueEnum;
6import com.rabbitmq.client.BuiltinExchangeType;
7import com.rabbitmq.client.Channel;
8import com.rabbitmq.client.DeliverCallback;
9import lombok.SneakyThrows;
10import lombok.extern.slf4j.Slf4j;
11
12/**
13 * 路由模式-消费者1
14 *
15 * @author futao
16 * Created on 2019-04-22.
17 */
18@Slf4j
19public class ConsumerOne {
20    @SneakyThrows
21    public static void main(String[] args) {
22        Channel channel = RabbitMqConnectionTools.getChannel();
23        //开启持久化队列
24        boolean durable = true;
25        channel.queueDeclare(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_ONE.getQueueName(), durable, false, false, null);
26        //定义交换器类型
27        channel.exchangeDeclare(ExchangeTypeEnum.DIRECT.getExchangeName(), BuiltinExchangeType.DIRECT);
28        //将消息队列与Exchange交换器与路由键绑定(同时订阅路由key为"log.info"和"log.error"的消息)
29        channel.queueBind(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_ONE.getQueueName(), ExchangeTypeEnum.DIRECT.getExchangeName(), "log.error");
30        channel.queueBind(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_ONE.getQueueName(), ExchangeTypeEnum.DIRECT.getExchangeName(), "log.info");
31        //告诉rabbitmq一次只发送一条消息,并且在前一个消息未被处理或者消费之前,不继续发送下一个消息
32        channel.basicQos(1);
33        log.info("Waiting for message...");
34        DeliverCallback deliverCallback = ((consumerTag, message) -> {
35            log.info("收到消息:[{}],routingKey:[{}],tag:[{}]", new String(message.getBody()), message.getEnvelope().getRoutingKey(), consumerTag);
36            //acknowledgment应答
37            channel.basicAck(message.getEnvelope().getDeliveryTag(), false);
38            try {
39                Thread.sleep(1000);
40            } catch (Exception e) {
41
42            }
43        });
44        //关闭自动应答
45        boolean autoAck = false;
46        channel.basicConsume(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_ONE.getQueueName(), autoAck, deliverCallback, consumerTag -> {
47        });
48    }
49}
50
  • 消费者2(只订阅路由key为"log.error"的消息)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
1package com.futao.springmvcdemo.mq.rabbit.routing;
2
3import com.futao.springmvcdemo.mq.rabbit.ExchangeTypeEnum;
4import com.futao.springmvcdemo.mq.rabbit.RabbitMqConnectionTools;
5import com.futao.springmvcdemo.mq.rabbit.RabbitMqQueueEnum;
6import com.rabbitmq.client.BuiltinExchangeType;
7import com.rabbitmq.client.Channel;
8import com.rabbitmq.client.DeliverCallback;
9import lombok.SneakyThrows;
10import lombok.extern.slf4j.Slf4j;
11
12/**
13 * 路由模式-消费者2
14 *
15 * @author futao
16 * Created on 2019-04-22.
17 */
18@Slf4j
19public class ConsumerTwo {
20    @SneakyThrows
21    public static void main(String[] args) {
22        Channel channel = RabbitMqConnectionTools.getChannel();
23        //开启持久化队列
24        boolean durable = true;
25        channel.queueDeclare(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_TWO.getQueueName(), durable, false, false, null);
26        //定义交换器类型
27        channel.exchangeDeclare(ExchangeTypeEnum.DIRECT.getExchangeName(), BuiltinExchangeType.DIRECT);
28        //将消息队列与Exchange交换器进行绑定(只订阅路由key为"log.error"的消息)
29        channel.queueBind(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_TWO.getQueueName(), ExchangeTypeEnum.DIRECT.getExchangeName(), "log.error");
30        //告诉rabbitmq一次只发送一条消息,并且在前一个消息未被处理或者消费之前,不继续发送下一个消息
31        channel.basicQos(1);
32        log.info("Waiting for message...");
33        DeliverCallback deliverCallback = ((consumerTag, message) -> {
34            log.info("收到消息:[{}],routingKey:[{}],tag:[{}]", new String(message.getBody()), message.getEnvelope().getRoutingKey(), consumerTag);
35            //acknowledgment应答
36            channel.basicAck(message.getEnvelope().getDeliveryTag(), false);
37            try {
38                Thread.sleep(2000);
39            } catch (Exception e) {
40
41            }
42        });
43        //关闭自动应答
44        boolean autoAck = false;
45        channel.basicConsume(RabbitMqQueueEnum.EXCHANGE_QUEUE_DIRECT_TWO.getQueueName(), autoAck, deliverCallback, consumerTag -> {
46        });
47    }
48}
49
  • 测试


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
1>>> 生产者
217:35:22.151 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!0log.info] ,routingKey:[log.info] success
317:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!1log.info] ,routingKey:[log.info] success
417:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!2log.info] ,routingKey:[log.info] success
517:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!3log.info] ,routingKey:[log.info] success
617:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!4log.info] ,routingKey:[log.info] success
717:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!5log.info] ,routingKey:[log.info] success
817:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!6log.info] ,routingKey:[log.info] success
917:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!7log.info] ,routingKey:[log.info] success
1017:35:22.156 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!8log.info] ,routingKey:[log.info] success
1117:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!9log.info] ,routingKey:[log.info] success
1217:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!10log.info] ,routingKey:[log.info] success
1317:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!11log.info] ,routingKey:[log.info] success
1417:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!12log.info] ,routingKey:[log.info] success
1517:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!13log.info] ,routingKey:[log.info] success
1617:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!14log.info] ,routingKey:[log.info] success
1717:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!15log.info] ,routingKey:[log.info] success
1817:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!16log.info] ,routingKey:[log.info] success
1917:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!17log.info] ,routingKey:[log.info] success
2017:35:22.157 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!18log.info] ,routingKey:[log.info] success
2117:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!19log.info] ,routingKey:[log.info] success
2217:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!0log.error] ,routingKey:[log.error] success
2317:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!1log.error] ,routingKey:[log.error] success
2417:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!2log.error] ,routingKey:[log.error] success
2517:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!3log.error] ,routingKey:[log.error] success
2617:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!4log.error] ,routingKey:[log.error] success
2717:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!5log.error] ,routingKey:[log.error] success
2817:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!6log.error] ,routingKey:[log.error] success
2917:35:22.158 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!7log.error] ,routingKey:[log.error] success
3017:35:22.159 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!8log.error] ,routingKey:[log.error] success
3117:35:22.159 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.Producer - Send msg:[Hello RabbitMq!9log.error] ,routingKey:[log.error] success
32Disconnected from the target VM, address: '127.0.0.1:58582', transport: 'socket'
33
34> 消费者1-同时订阅了路由键为`log.info`和`log.error`的消息
35
3617:35:15.737 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerOne - Waiting for message...
3717: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]
3817: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]
3917: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]
4017: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]
4117: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]
4217: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]
4317: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]
4417: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]
4517: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]
4617: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]
4717: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]
4817: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]
4917: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]
5017: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]
5117: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]
5217: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]
5317: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]
5417: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]
5517: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]
5617: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]
5717: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]
5817: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]
5917: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]
6017: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]
6117: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]
6217: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]
6317: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]
6417: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]
6517: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]
6617: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]
67
68> 消费者2-只订阅了路由键为`log.error`的消息
6917:35:18.722 [main] INFO com.futao.springmvcdemo.mq.rabbit.routing.ConsumerTwo - Waiting for message...
7017: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]
7117: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]
7217: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]
7317: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]
7417: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]
7517: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]
7617: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]
7717: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]
7817: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]
7917: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]
80
「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!