V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
4rfv5tgb
V2EX  ›  程序员

关于消息队列

  •  1
     
  •   4rfv5tgb · 2022-04-15 23:19:43 +08:00 · 877 次点击
    这是一个创建于 763 天前的主题,其中的信息可能已经有所发展或是发生改变。

    萌新初学消息队列, 不懂就问。今天看了下 rabbitmq 的文档,有关于 prefetch_count 的设置,这个是设置消费者能拥有最多的未 ack 的消息的数量。我看官方文档说, 即使重新入队也会保证顺序。假设单个消费者,生产者发送消息 1->2->3->4->5->6->7->8->9->10, 如果 prefetch_count 设置成 30 ,那么假如 5 消息失败了没有手动 ack ,requeue 重新入队。但是 6 ,7 ,8 ,9 ,10 消费成功并且都 ack 了,这时候虽然消息看起来是按照顺序 push 了,但是消息这边消费的顺序有没有可能是 1->2->3->4->6->7->8->9->10->5 这样的顺序。我有这样的疑问:

    1.在需要保证顺序的场景,现实场景中上面的情况大家都是怎么做的呢?

    2.消息是否有必要持久化落表?比如说记录消费失败的 message

    附上文档:

    Message ordering guarantees
    Section 4.7 of the AMQP 0-9-1 core specification explains the conditions under which ordering is guaranteed: messages published in one channel, passing through one exchange and one queue and one outgoing channel will be received in the same order that they were sent. RabbitMQ offers stronger guarantees since release 2.7.0.
    
    Messages can be returned to the queue using AMQP methods that feature a requeue parameter (basic.recover, basic.reject and basic.nack), or due to a channel closing while holding unacknowledged messages. Any of these scenarios caused messages to be requeued at the back of the queue for RabbitMQ releases earlier than 2.7.0. From RabbitMQ release 2.7.0, messages are always held in the queue in publication order, even in the presence of requeueing or channel closure.
    
    With release 2.7.0 and later it is still possible for individual consumers to observe messages out of order if the queue has multiple subscribers. This is due to the actions of other subscribers who may requeue messages. From the perspective of the queue the messages are always held in the publication order.
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2531 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 07:40 · PVG 15:40 · LAX 00:40 · JFK 03:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.