簡體   English   中英

Spring Cloud Stream不會創建隊列

[英]Spring Cloud Stream does not create a queue

我正在嘗試使用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。

一旦啟動消費者應用程序,就會創建一個隊列。

對於Rabbit MQ,我們為每個使用者組分別設置了隊列,並且我們事先無法知道所有組,如果您希望為事先已知的使用者組自動創建隊列,則可以使用該組的requiredGroups屬性。生產者。 這將確保消息持續存在,直到啟動該組的使用者。

詳情請見: http//docs.spring.io/spring-cloud-stream/docs/Brooklyn.BUILD-SNAPSHOT/reference/htmlsingle/#_producer_properties

您需要一個消費者才能創建一個隊列。

在這里,您可以找到使用rabbitMq的生產者和消費者的示例:

http://ignaciosuay.com/how-to-implement-asyncronous-communication-between-microservices-using-spring-cloud-stream/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM