rabbitMq可靠消息投递之交换机备份
作者:互联网
//备份队列 @Bean("alternate_queue") public Queue alternate_queue() { return new Queue("alternate_queue", true); } //备份交换机 @Bean("alternate_exchange") public TopicExchange alternate_exchange() { return new TopicExchange("alternate_exchange", true, false); } //备份队列 @Bean("backBinding") public Binding backBinding(@Qualifier("alternate_queue") Queue third,@Qualifier("alternate_exchange")TopicExchange exchange) { return BindingBuilder.bind(third).to(exchange).with("#");//备份交换机是无条件的路由键 } //给自己留一个备份交换机 alternate_exchange @Bean("firstExchange") public FanoutExchange firstExchange() { //声明交换机的时候指定备份交换机 Map<String,Object> arguments=new HashMap<>(); arguments.put("alternate-exchange","alternate_exchange"); return new FanoutExchange("firstExchange", true, false,arguments); } @Bean("firstBinding") public Binding firstBinding(@Qualifier("first") Queue first,@Qualifier("firstExchange")FanoutExchange exchange) { return BindingBuilder.bind(first).to(exchange); } @Bean("first") public Queue first() { return new Queue("first", true); }
标签:return,可靠消息,exchange,alternate,rabbitMq,Queue,Bean,交换机,public 来源: https://www.cnblogs.com/wangbiaohistory/p/14630814.html