【发布时间】:2019-05-16 21:08:17
【问题描述】:
我有一个应用程序充当发布者并定期将消息发送到交换器和其他十几个按主题在语义上摸索的应用程序(订阅者)。我的问题是订阅者可以在不同的组之间移动,因此他们的主题订阅应该改变,但我不知道如何动态改变绑定。有什么想法吗?
每个订阅者的配置如下所示:
@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);
}
}
P.S:我的Subscriber SpringBoot应用一定不能重启,否则很明显。
【问题讨论】: