Azure 服务总线有序处理消息

标签 azure azureservicebus servicebus azure-servicebus-topics

如果对于 Azure 服务总线主题,则存在带有某些筛选器的单个订阅。有一个微服务 A 创建了 SubscriptionClient对于读取消息并发度为 1 的订阅。此外,如果该服务 A 有 2 个这样的副本,并且假设 unpartitioned 中有 3 条消息。服务总线主题在 t1、t2 和 t3 时间插入主题。

t1 < t2 < t3

  1. 是否有可能在 t1 传递到 Replica-1 之前,t2 消息可以通过服务总线传递到 Replica-2?

  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.

message ordering

服务总线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/

相关文章:

azure - 告诉 AzCopy 批处理覆盖文件?

azure - 一次部署具有多个主题和队列的 ServiceBus

c# - Azure 服务总线广播到所有辅助角色实例

azure - 本地 NServicebus 应用程序从 Azure ServiceBus 队列接收消息

c# - 使用 Azure.Messaging.ServiceBus.Administration 创建 ServiceBus 队列时出错

c# - 在 azure 上运行时访问本地文件

Azure - Azure 中内部角色之间的安全通信

Azure 服务总线 - 使用 BrokeredMessage.GetBody 读取 .NET Core 2 发送的消息

Azure 移动后端中的 Azure 存储连接字符串主键

azure - 在消息服务总线中发送 XML 并在逻辑应用中解析它