有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JavaSpringAMQP无法创建bean来返回列表<Binding>

我正在尝试使用SpringAMQP,版本2.1.2。release,以创建到主题交换的多个绑定

我发现了这个问题:How to setup multiple topics in a RabbitMQ Java config class using Spring Framework?

这似乎有答案。我还找到了documention,它提供了相同的解决方案

但是,当我在Bean中返回一个列表时,并没有创建绑定。如果我返回一个绑定,那么它就工作了。由于缺乏声誉,我不能对这个问题发表评论

这是我的密码:

    @Bean
public TopicExchange topicExchange() {
    return new TopicExchange("topicExchange");
}

@Bean
public Queue testQueue() {
    return new Queue("testQueue");
}

@Bean
List<Binding> multipleBindings() {
    return Arrays.asList(
            BindingBuilder.bind(testQueue()).to(topicExchange()).with("t1"),
            BindingBuilder.bind(testQueue()).to(topicExchange()).with("t2"));
}

@Bean
Binding singleBinding() {
    return BindingBuilder.bind(testQueue()).to(topicExchange()).with("t3");
}

在这段代码中,我得到了“t3”主题绑定,但在查看兔子管理控制台时没有看到“t1”或“t2”

请提供帮助,因为此代码看起来非常简单,并且遵循文档。我错过了什么

多谢各位


共 (1) 个答案