2016-09-17 1 views
0

RabbitMQ로 간단한 Spring Cloud Stream 애플리케이션을 구성하려고합니다. 내가 사용하는 코드는 대부분 spring-cloud-stream-samples에서 가져온 것입니다. 나는를 실행하면Spring Cloud Stream에서 대기열을 만들지 않습니다.

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

:

@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 구성입니다 예를 들어, Rabbit에 연결하여 test라는 교환을 만듭니다. 하지만 내 문제는 큐 및 바인딩 자동으로 만들어지지 않습니다. 나는 Rabbit에가는 트래픽을 볼 수 있지만 내 모든 메시지는 사라집니다. 소비자가 읽지 않는 한 대기열에 있어야합니다.

어쩌면 내가 오해 할 수도 있지만, 읽은 모든 주제에서 볼 때 Spring Cloud Stream은 큐와 바인딩을 자동으로 생성해야하는 것처럼 보인다. 그렇지 않은 경우 내 메시지가 유지되도록 어떻게 구성합니까?

저는 Spring Cloud Brixton.SR5 및 Spring Boot 1.4.0.RELEASE를 사용하고 있습니다.

답변

2

소비자 응용 프로그램을 시작하자마자 대기열이 생성됩니다.

미리 정의 된 소비자 그룹에 대해 대기열을 자동으로 생성하려면 각 소비자 그룹에 대해 별도의 대기열이 있고 모든 그룹을 미리 알 수없는 Rabbit MQ의 경우 requiredGroups 프로듀서의 속성. 이렇게하면 해당 그룹의 사용자가 시작될 때까지 메시지가 지속됩니다.

여기에서 자세한 내용을 참조하십시오 http://docs.spring.io/spring-cloud-stream/docs/Brooklyn.BUILD-SNAPSHOT/reference/htmlsingle/#_producer_properties

+0

예, 작동! 고맙습니다. – FVlad