首页 > 解决方案 > 更改 RabbitMQ 绑定

问题描述

我有一个应用程序充当发布者并定期将消息发送到交换和其他十几个(订阅者),这些应用程序在语义上被主题摸索。我的问题是订阅者可以在不同的组之间移动,因此他们的主题订阅应该改变,但我不知道如何动态改变绑定。有任何想法吗?

我对每个订阅者的配置如下所示:

@Bean
TopicExchange exchange() {
    return new TopicExchange(exchangeName);
}

@Bean
Binding binding(Queue queue, TopicExchange exchange) {
    return BindingBuilder.bind(queue).to(exchange).with(routingKey);
}

@Bean
Queue queue(SystemInformationService systemInformationService) {
    return new Queue(systemInformationService.getInfo().getTemplateName() != null ?  systemInformationService.getInfo().getTemplateName() : queueName , true);
}

}

PS:一定不能重启我的Subscriber SpringBoot应用,不然就很明显了。

标签: rabbitmqspring-rabbit

解决方案


您不能更改绑定;但是,您可以添加和删除它们。

您可以使用管理 UI 手动执行此操作,也可以使用RabbitAdmin.


推荐阅读