Azure事件中心更改分区键 [英] Azure Event Hubs Changing Partition Key

查看:87
本文介绍了Azure事件中心更改分区键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序在启动时会将EventData.PartitionKey的值设置为新的Guid.因此,对于每个新的部署,分区密钥都会更改.

An application sets the value of EventData.PartitionKey to a new Guid upon start-up. For each new deployment, the Partition Key will therefore change.

我知道事件中心利用哈希机制将消息路由到特定分区.重新生成分区密钥是否会以任何有害的方式阻碍或影响该机制?

I understand that Event Hubs leverage a hashing mechanism in order to route messages to specific Partitions. Does regenerating the Partition Key impede, or affect, this mechanism in any detrimental way?

尽管有时基础EventHubClient.SendBatchAsync方法不会抛出Exception事实,但我不时注意到在多次部署之后消息不会出现在事件中心中(无论经过了多长时间).该行为似乎可以自行纠正.

I notice from time to time that messages do not appear in the Event Hub (regardless of how much time has passed) after multiple deployments, despite the fact that the underlying EventHubClient.SendBatchAsync method does not throw an Exception. The behaviour appears to correct itself arbitrarily.

推荐答案

影响将是:每次您的App重新启动时-消息可能会进入完全不同的分区中-因为新的Guid可能会散列到不同的EventHub分割.

这不会以任何方式损害EventHub的性能.您可以根据需要生成任意数量的PartitionKey.

但是,使用这些事件的应用程序会受到影响:通常会有一个Worker在单一分区之外处理事件( EventHubs分区是事件处理器将事件处理出去的规模单位) EventHubs ).当您的应用程序以Guid1开头时-可能会被哈希到由ProcessorInstance1处理的Partition1,但是,当应用程序重新启动时,它将生成Guid2并可能被哈希到被ProcessorInstance10处理的Partition10.使用PartitionKey的任何应用程序背后的原理是 Correlation -所有使用相同PartitionKeyEventData都将落在Same EventHub分区上.但是,此密钥已被重置-破坏了整个目的.

如果操作失败,则所有SendBatch操作都将引发.这是最基本的保证.不可能的SLA违反-如果没有违反.我相信,根据您所解释的症状,在应用程序部署之后,由于新的Guid会导致事件降落在不同的分区上-您可能正在从特定的分区&接收事件.可能会看不见他们&如果您生成另一个映射到旧分区的Guid,它可能会自动更正...我强烈建议将partitionKey的映射固定为random Guid.

The impact would be: each time your App restarts - the messages could land in an entirely different Partition - because, the new Guid could be hashed to a different EventHub Partition.

This wouldn't hurt EventHub performance in any way. You can generate as many PartitionKey's as you need.

But, the Application consuming these events would be impacted: typically there would be one Worker processing the events out of a Single-Partition (EventHubs partitions are the Unit-of-Scale for the event-processers processing events out of EventHubs). When your App started with Guid1 - it might be hashed to Partition1 which is being processed by ProcessorInstance1, but, when the App restarts - it would generate Guid2 which might be hashed to Partition10 which is being processed by ProcessorInstance10. The principle behind any Application using PartitionKey is Correlation - all EventData's using the same PartitionKey would land on Same EventHub partition. But, this key is being reset - which defeats the whole purpose.

All SendBatch Operations will throw if the operation doesn't succeed. This is the fundamental guarantee & an impossible SLA breach - if it doesn't throw. I believe, from the symptoms you explained, after an App deployment, since the new Guid will result into events landing on different partitions - you might be receiving events out of a specific partition & could be missing to see them & it could auto-correct if you generate another Guid which maps to old Partition... I would strongly recommend to fix the Map of partitionKey to a randomGuid.

有关事件中心的更多信息...

这篇关于Azure事件中心更改分区键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆