spring amqp代码生成rabbitmq的exchange and queue
@configuration
public class fanoutconfigure {
    @bean
    public fanoutexchange fanoutexchange() {
        return exchangebuilder.fanoutexchange(fanout_builder_exchange_name).build();
//        return new fanoutexchange(fanout_builder_exchange_name);
    }
    @bean
    public queue fanoutqueue() {
//        return new queue(fanout_builder_queue_name, true);
        return queuebuilder.durable(fanout_builder_queue_name).build();
    }
    @bean
    public binding fanoutbinding(fanoutexchange fanoutexchange, queue fanoutqueue) {
        // .with 实现 routingkey 的匹配
        return bindingbuilder.bind(fanoutqueue).to(fanoutexchange);
    }
}直接上代码
    public static final string fanout_builder_exchange_name = "fanoutbuild.exchange";
    public static final string fanout_builder_queue_name = "fanoutbuild.queue";执行结果


绑定关系成立。
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
 
             我要评论
我要评论 
                                             
                                             
                                             
                                             
                                             
                                            
发表评论