繁体   English   中英

Spring 云 Stream 与 RabbitMQ 流

[英]Spring Cloud Stream with RabbitMQ Streams

我正在尝试使用“函数式编程模型”将 RabbitMQ 的“新”Streams 插件与我的 spring-cloud-stream 项目一起使用。

我已经像这样设置了我的 application.yaml:

spring:
  rabbitmq:
    listener:
      type: stream
    stream:
      host: ${RABBIT_HOST:localhost}
      port: ${RABBIT_PORT:5672}
      username: guest
      password: guest
      name: demo
  cloud:
    function:
      definition: testConsumer
    stream:
      rabbit:
        bindings:
          testConsumer-in-0:
            consumer:
              containerType: stream
      bindings:
        testConsumer-in-0:
          group: demo
          destination: test
        testProducer-out-0:
          destination: test

我有一个使用 StreamBridge 的 @PostConstruct 方法,如下所示:

streamBridge.send("testProducer-out-0", "testing..");

我的 testconsumer 看起来像这样:

@Bean
public Consumer<Flux<String>> testConsumer() {
    return flux -> flux.doOnEach(LOGGER::info);
}

但是当我启动我的应用程序时,我得到了这个异常:

Caused by: com.rabbitmq.stream.StreamException: Could not get response in 10000 ms

在我的 RabbitMQ 容器的日志中,我收到此错误:

2022-09-14 13:30:53.485574+00:00 [error] <0.32309.0> {bad_header,<<0,0,1,0,0,17,0,1>>}

如果我将 spring.cloud.stream.rabbit.bindings.testConsumer-in-0.consumer.containerType 设置为direct,一切正常。

有谁知道为什么?

看起来您正在尝试通过 AMQP 端口进行连接,而不是 stream 端口。

stream 端口为 5552。

您是否在映射流端口并启用插件? https://blog.rabbitmq.com/posts/2021/07/rabbitmq-streams-first-application/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM