首页 文章

Spring Cloud Stream不会创建队列

提问于
浏览
1

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

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

和示例中的简单消息生成器:

@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()));
    }

}

另外,这是application.yml配置:

fixedDelay: 5000
spring:
  cloud:
    stream:
      bindings:
        output:
          destination: test

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

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

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

2 回答

相关问题