首页>代码>springboot+rabbitmq整合简单消息队列示例>/mq-demo/consumer/src/main/java/com/liangzi/mq/config/FanoutConfig.java
package com.liangzi.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutConfig {
    // itcast.fanout
    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("itcast.fanout");
    }

    // fanout.queue1
    @Bean
    public Queue fanoutQueue1(){
        return new Queue("fanout.queue1");
    }

    // 绑定队列1到交换机
    @Bean
    public Binding fanoutBinding1(Queue fanoutQueue1, FanoutExchange fanoutExchange){
        return BindingBuilder
                .bind(fanoutQueue1)
                .to(fanoutExchange);
    }

    // fanout.queue2
    @Bean
    public Queue fanoutQueue2(){
        return new Queue("fanout.queue2");
    }

    // 绑定队列2到交换机
    @Bean
    public Binding fanoutBinding2(Queue fanoutQueue2, FanoutExchange fanoutExchange){
        return BindingBuilder
                .bind(fanoutQueue2)
                .to(fanoutExchange);
    }

    @Bean
    public Queue objectQueue(){
        return new Queue("object.queue");
    }
}
最近下载更多
youwuzuichen  LV11 5月29日
微信网友_7134912998903808  LV15 2024年9月11日
zhujunnan  LV12 2024年3月19日
erqiu2013  LV18 2023年12月27日
Seaskye  LV14 2023年11月10日
shuangfu  LV25 2023年10月19日
杨豫川  LV12 2023年4月27日
sunlzh888888  LV29 2023年4月23日
quyiyi  LV3 2023年4月5日
最代码官方  LV168 2022年10月22日
最近浏览更多
andy_伟  LV6 8月18日
dane168  LV10 8月5日
youwuzuichen  LV11 5月29日
charleswang  LV7 2024年10月21日
微信网友_7134912998903808  LV15 2024年9月11日
TY0165  LV20 2024年6月17日
kenhomeliu  LV29 2024年4月30日
jc121140  LV3 2024年3月25日
zhujunnan  LV12 2024年3月5日
erqiu2013  LV18 2023年12月27日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友