繁体   English   中英

Spring 云 Stream + RabbitMQ - 使用队列中的现有消息

[英]Spring Cloud Stream + RabbitMQ - Consuming existing messages in queue

我有一个在服务器中运行的 RabbitMQ 消息代理,我正在尝试使用 Spring Cloud Stream 配置生产者和消费者。 我的生产者每秒都在队列中创建消息,而我的消费者以相同的速度读取它们。 但是,如果我停止我的消费者并且生产者继续推送消息,当我再次重新启动我的消费者时,它无法检索在它关闭的那段时间创建的消息,只能拾取从它启动时产生的消息. 如何让我的消费者在启动时使用队列中的现有消息?

这是我的消费者属性:

cloud:
    stream:
      bindings:
        input:
          destination: spring-cloud-stream-demo
          consumer:
            auto-bind-dlq: true
            republishToDlq: true
            maxAttempts: 5

还有我的 Producer 属性:

cloud:
    stream:
      bindings:
        output:
          destination: spring-cloud-stream-demo

感谢任何帮助!

您需要在消费者(输入)绑定中添加一个group 否则它将绑定一个匿名的、自动删除的队列到交换器。

使用group ,则绑定一个永久的、持久的队列。

我也有一个问题。 在消费者起床之前,我向生产者发送数据。 一段时间后,我唤醒了消费者。 消费者收到打印的数据,因为它站起来。 所以它不会从一开始就进行阅读。 有没有什么办法解决这一问题? ——加里·罗素

暂无
暂无

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

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