liusheng
2024-05-12 f243bb8af00a2464d16536d42150a4107f87b4ae
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
//package com.smartor.config;
//
//import org.springframework.amqp.core.*;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//import java.util.Map;
//
////@Configuration
//public class RabbitMqConfig {
//
////定义延迟队列
//    public static final String phone_queue = "phone_queue";
//    //定义延迟交换机
//    public static final String phone_exchange = "phone_exchange";
//    //定义路由键
//    public static final String routing_key = "phone.123";
//
//
//    /**
//     * 定义延迟队列
//     *
//     * @return
//     */
//    @Bean
//    public Queue delayQueue() {
//        return new Queue(phone_queue, true);
//    }
//
//    /**
//     * 延时队列交换机
//     * 交换机类型:CustomExchange
//     *
//     * @return
//     */
//    @Bean
//    public CustomExchange delayExchange() {
//        Map<String, Object> args = new HashMap<>();
//        args.put("x-delayed-type", "topic");
//        return new CustomExchange(phone_exchange, "x-delayed-message", true, false, args);
//    }
//
//    /**
//     * 为延迟队列绑定交换机
//     *
//     * @param queue
//     * @param exchange
//     * @return
//     */
//    @Bean
//    public Binding delayBinding(Queue queue, CustomExchange exchange) {
//        return BindingBuilder.bind(queue).to(exchange).with(routing_key).noargs();
//    }
//
//}