为什么 Azure 事件中心 EventData 的 PartitionKey 字段为空?
Why is the PartitionKey field of an Azure Event Hub EventData null?
我正在使用 Azure Functions 1.x 使用来自 Azure 事件中心的 EventData
个事件。但是,我注意到 PartitionKey
始终为空。然而,Offset
和 SequenceNumber
都已填充。
我知道发件人可以选择设置 PartitionKey
。事实上,出于性能考虑,不设置它是recommended。但是,我假设在到达消费者的某个地方,PartitionKey
将设置为处理 EventData
.
的分区
如果不是这样,发送 Offset
和 SequenceNumber
有什么意义?每个分区维护自己的 Offset
和 SequenceNumber
。如果我想重播一个事件,我该如何在不知道 PartitionKey
?
的情况下这样做
编辑:
我刚刚发现,如果我绑定到 PartitionContext
,我可以查看 EventData
来自的 PartitionId
。为什么不将其用于填充 EventData
上的 PartitionKey
?这是 Azure Functions 的错误吗?
您应该能够从 EventData 对象中获取 partitionKey 属性。请看,https://medium.com/@jeffhollan/in-order-event-processing-with-azure-functions-bb661eb55428
PartitionKey
是 different 来自 PartitionId
:
PartitionId is different than PartitionKey. Partition keys are used to
ensure same partition keys to land on the same partition ids. You can
think PartitionKey to partitionId relation as "f(partitionKey) =
partitionId" where f is a hashing function.
如所述,如果发件人未设置,PartitionKey
将为空。
您可以使用 PartitionContext
绑定访问 Azure Functions 中的 PartitionId
。
我正在使用 Azure Functions 1.x 使用来自 Azure 事件中心的 EventData
个事件。但是,我注意到 PartitionKey
始终为空。然而,Offset
和 SequenceNumber
都已填充。
我知道发件人可以选择设置 PartitionKey
。事实上,出于性能考虑,不设置它是recommended。但是,我假设在到达消费者的某个地方,PartitionKey
将设置为处理 EventData
.
如果不是这样,发送 Offset
和 SequenceNumber
有什么意义?每个分区维护自己的 Offset
和 SequenceNumber
。如果我想重播一个事件,我该如何在不知道 PartitionKey
?
编辑:
我刚刚发现,如果我绑定到 PartitionContext
,我可以查看 EventData
来自的 PartitionId
。为什么不将其用于填充 EventData
上的 PartitionKey
?这是 Azure Functions 的错误吗?
您应该能够从 EventData 对象中获取 partitionKey 属性。请看,https://medium.com/@jeffhollan/in-order-event-processing-with-azure-functions-bb661eb55428
PartitionKey
是 different 来自 PartitionId
:
PartitionId is different than PartitionKey. Partition keys are used to ensure same partition keys to land on the same partition ids. You can think PartitionKey to partitionId relation as "f(partitionKey) = partitionId" where f is a hashing function.
如PartitionKey
将为空。
您可以使用 PartitionContext
绑定访问 Azure Functions 中的 PartitionId
。