简体   繁体   English

如何在 Azure 事件中心仅读取一次事件

[英]How to read event only once in Azure Event Hub

I want to read events only once from Azure Event hub so that event gets processed only once.我只想从 Azure 事件中心读取事件一次,以便事件只处理一次。 But while reading these events getting same event in all partitions.但是在读取这些事件时,所有分区中的事件都相同。

Tech Stack - Spring boot to read events via技术堆栈 - Spring 启动以通过以下方式读取事件

EventProcessorHost host = EventProcessorHost.EventProcessorHostBuilder
            .newBuilder(EventProcessorHost.createHostName(hostNamePrefix), 
consumerGroupName)
            .useAzureStorageCheckpointLeaseManager(storageConnectionString, storageContainerName, null)
            .useEventHubConnectionString(eventHubConnectionString.toString(), eventHubName)
            .build();

Thanks.谢谢。

You can create up to 32 partition on Eventhub but when you send a message that will go only on single partition (if you would not put partition-id , Eventhub will send message to random partition )您最多可以在 Eventthub 上创建32分区,但是当您发送的消息只在单个分区上发送时(如果您不放置partition-id ,Eventhub 将发送消息到随机分区)

Event Hubs retains data for a configured retention time that applies across all partitions in the event hub.事件中心在配置的保留时间内保留数据,该保留时间适用于事件中心中的所有分区。 Events expire on a time basis;事件按时间到期; you cannot explicitly delete them.您不能明确删除它们。 Because partitions are independent and contain their own sequence of data, they often grow at different rates.因为分区是独立的并且包含自己的数据序列,所以它们通常以不同的速度增长。 partitions 分区

maybe issue with your code, To confirm this behaviour you can use Microsoft ServiceBusExplorer to send and receive messages from Eventhub.您的代码可能有问题,要确认此行为,您可以使用 Microsoft ServiceBusExplorer从 Eventhub 发送和接收消息。 When you will create Eventhub listener through Service bus you can receive partition-id and messages in real-time.当您通过服务总线创建 Eventthub 侦听器时,您可以实时接收分区 ID 和消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM