Spring Cloud Stream 不创建队列

FVl*_*lad 2 spring spring-cloud-stream

我正在尝试使用 RabbitMQ 配置一个简单的 Spring Cloud Stream 应用程序。我使用的代码主要来自spring-cloud-stream-samples。我有一个切入点:

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
Run Code Online (Sandbox Code Playgroud)

以及示例中的简单消息生产者:

@EnableBinding(Source.class)
public class SourceModuleDefinition {

    private String format = "yyyy-MM-dd HH:mm:ss";

    @Bean
    @InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "${fixedDelay}", maxMessagesPerPoll = "1"))
    public MessageSource<String> timerMessageSource() {
        return () -> new GenericMessage<>(new SimpleDateFormat(this.format).format(new Date()));
    }

}
Run Code Online (Sandbox Code Playgroud)

此外,这里是 application.yml 配置:

fixedDelay: 5000
spring:
  cloud:
    stream:
      bindings:
        output:
          destination: test
Run Code Online (Sandbox Code Playgroud)

当我运行该示例时,它连接到 Rabbit 并创建一个名为 test 的交换。但我的问题是,它不会自动创建队列和绑定。我可以看到 Rabbit 中的流量,但是我所有的消息都消失了。虽然我需要它们留在某个队列中,除非消费者读取它们。

也许我误解了一些东西,但从我阅读的所有主题来看,Spring Cloud Stream 似乎应该自动创建一个队列和一个绑定。如果没有,我如何配置它以便我的消息被持久化?

我正在使用 Spring Cloud Brixton.SR5 和 Spring Boot 1.4.0.RELEASE。

Mar*_*ici 6

一旦您启动消费者应用程序,就会创建一个队列。

在Rabbit MQ的情况下,我们为每个消费者组都有单独的队列,我们​​不能事先知道所有组,如果你想为预先知道的消费者组自动创建队列,你可以使用requiredGroups生产者的属性. 这将确保消息被持久化,直到来自该组的消费者被启动。

在此处查看详细信息:http : //docs.spring.io/spring-cloud-stream/docs/Brooklyn.BUILD-SNAPSHOT/reference/htmlsingle/#_producer_properties