如果对于 Azure 服务总线主题,则存在带有某些筛选器的单个订阅。有一个微服务 A 创建了 SubscriptionClient
对于读取消息并发度为 1 的订阅。此外,如果该服务 A 有 2 个这样的副本,并且假设 unpartitioned
中有 3 条消息。服务总线主题在 t1、t2 和 t3 时间插入主题。
t1 < t2 < t3
是否有可能在 t1 传递到 Replica-1 之前,t2 消息可以通过服务总线传递到 Replica-2?
如果没有,在处理订阅和添加消费微服务副本时服务总线主题的扩展策略是什么。
注意:与kafka相比,它确保1个分区的消息仅传递到一个副本和一个正在监听该分区的线程,从而保证消息的有序处理。但不确定像 Azure 服务总线这样的服务总线主题,如果多个副本正在使用不同的订阅客户端监听同一订阅,它们是否可以接收/处理无序消息?
最佳答案
如果要使用 Azure 服务总线启用有序消息处理,则必须使用 Sessions 。
您可以使用消息的 SessionId
作为您在 Kafka 中使用的分区 ID 的等效项。这样,您仍然可以扩展您的消费者,但受到任何给定时间不同 SessionId
值数量的限制。
Message sessions. Implement workflows that require message ordering or message deferral.
Sessions provide concurrent de-multiplexing of interleaved message streams while preserving and guaranteeing ordered delivery.
When multiple concurrent receivers pull from the queue, the messages belonging to a particular session are dispatched to the specific receiver that currently holds the lock for that session. With that operation, an interleaved message stream in one queue or subscription is cleanly de-multiplexed to different receivers and those receivers can also live on different client machines, since the lock management happens service-side, inside Service Bus.
服务总线Partitions将负载分散到多个节点,并且不提供任何排序保证。
Partitioning means that the overall throughput of a partitioned entity is no longer limited by the performance of a single message broker or messaging store. In addition, a temporary outage of a messaging store does not render a partitioned queue or topic unavailable.
关于Azure 服务总线有序处理消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61096717/