如果在使用@RabbitListener`@EnableRabbit注解之前没有在rabbitmq管理界面上创建exchange和queue,绑定规则,那么就可以在程序中使用AmqpAdmin管理组件
测试类中添加,
@Autowired
AmqpAdmin amqpAdmin;
@Test
public void createExchange(){
amqpAdmin.declareExchange(new DirectExchange("amqpadmin.exchange"));
amqpAdmin.declareQueue(new Queue("amqpadmin.queue",true));
amqpAdmin.declareBinding(new Binding("amqpadmin.queue",Binding.DestinationType.QUEUE,"amqpadmin.exchange","amqp.haha",null));
}
运行测试类
标签:springboot,exchange,queue,组件,new,amqpAdmin,AmqpAdmin,amqpadmin From: https://blog.51cto.com/u_12528551/5900183