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);
}
本文来自博客园,作者:余生请多指教ANT,转载请注明原文链接:https://www.cnblogs.com/wangbiaohistory/p/14630814.html

浙公网安备 33010602011771号