我正在尝试使用RabbitMQ配置简单的Spring云流应用程序。我使用的代码大多取自spring-cloud-stream-samples。 我有一个入口点:Spring云流不会创建队列
@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。
是的,它的作品!谢谢。 – FVlad