xiaoyong931011
2023-08-01 8e6989a4472063a2edb5e63c16610ccf8450a562
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
package cc.mrbird.febs.rabbit;
 
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
 
import javax.annotation.Resource;
 
/**
 * @author wzy
 * @date 2022-05-31
 **/
@Configuration
public class RabbitConfiguration {
 
    @Resource
    private ConnectionFactory connectionFactory;
 
    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public RabbitTemplate rabbitTemplate() {
        return new RabbitTemplate(connectionFactory);
    }
 
    // === speed 支付订单  start ===
    @Bean
    public DirectExchange speedPayOrderExchange() {
        return new DirectExchange(QueueEnum.SPEED_PAY_ORDER.getExchange());
    }
 
    @Bean
    public Queue speedPayOrderQueue() {
        return new Queue(QueueEnum.SPEED_PAY_ORDER.getQueue());
    }
 
    @Bean
    public Binding speedPayOrderBind() {
        return BindingBuilder.bind(speedPayOrderQueue()).to(speedPayOrderExchange()).with(QueueEnum.SPEED_PAY_ORDER.getRoute());
    }
    // === speed 支付订单  end ===
 
    // === speed 代理升级  start ===
    @Bean
    public DirectExchange speedLevelUpExchange() {
        return new DirectExchange(QueueEnum.SPEED_LEVEL_UP.getExchange());
    }
 
    @Bean
    public Queue speedLevelUpQueue() {
        return new Queue(QueueEnum.SPEED_LEVEL_UP.getQueue());
    }
 
    @Bean
    public Binding speedLevelUpBind() {
        return BindingBuilder.bind(speedLevelUpQueue()).to(speedLevelUpExchange()).with(QueueEnum.SPEED_LEVEL_UP.getRoute());
    }
    // === speed 代理升级  end ===
}