Azure事件中心-顺序接收事件 [英] Azure Event Hub - Receiving events Sequentially
问题描述
我正在使用以下代码从Azure Event-Hub接收事件
I am using below code receive the events from Azure Event-Hub
我想按顺序处理进入事件中心的请求.例如,某人在很短的时间内发送了5个事件,我想完成请求1的处理,然后我要处理第二个请求.
I want to Handle the requests coming to event-hub Sequentially. For example someone sent 5 events in very quick time, I want to complete request 1 processing then i want take the second request to process.
我如何依次处理进入事件中心的事件?
How can i handle the events coming to event-hub Sequentially?
推荐答案
事件中心使用分区来启用事件处理的水平缩放.您可以在创建事件中心的过程中将分区数指定为1到32.仅保证一个分区内的消息顺序,而不能保证所有分区之间的消息顺序.
Event Hub uses partitions to enable horizontal scaling of event processing. You can specify number of partitions during the event hub creation from 1 to 32. Message order is guaranteed only within a partition but not across all partitions.
如果需要维护顺序,则只需将事件写入特定分区,而只能从同一分区读取.在Azure Event Hub中,分区分布在不同的实例中,以实现高可用性.这意味着分区可能会脱机以进行维护,然后再联机.因此,如果要管理订单,则需要写入和读取单个分区,并且可能需要手动管理诸如分区从应用程序逻辑脱机的情况.
If you need the order to be maintained, you need to write events only to a specific partition and read only from the same partition. In Azure Event Hub, partitions are distributed across different instances for high availability. Which means, a partition may go offline for maintenance and come online later. So if you wanted to manage order, you need to write and read to a single partition and you may need to manually manage situations such as partition go offline from your application logic.
如果您需要管理订单,我建议使用Azure Service Bus队列,该订单&可用性由服务总线自行管理.
If you need to manage order, I would recommend using Azure Service Bus queue which order & availability is managed by Service bus it self.
这篇关于Azure事件中心-顺序接收事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!