是否可以配置 Azure 事件中心以在 Azure 函数处理失败时保留消息?

Is it possible to configure Azure Event Hub to retain message if Azure Function fails processing it?

我有一个 Azure 函数用于侦听事件中心中的消息。该函数从事件中心获取消息,对其进行处理,然后将它们传递到另一个中心。此时消息已从事件中心删除。

如果 Function 由于某种原因未能处理消息,是否可以告诉 Event Hub 不要删除消息,并在将来的某个时间再次尝试将其传递给 Function?

我了解事件中心的最长保留期为 7 天。我希望事件中心和功能在此期间继续尝试。

读者永远不会 "remove" 来自事件中心的消息。它们在这一点上不同于服务总线主题和队列。

事件中心依靠客户端为每个分区维护自己的书签。高级 API EventProcessorHost 为您完成:

The EventProcessorHost class also implements an Azure storage-based checkpointing mechanism. This mechanism stores the offset on a per partition basis, so that each consumer can determine what the last checkpoint from the previous consumer was.

但较低级别 EventHubReceiver exposes the StartingSequenceNumber 属性 供您明确控制。

然而,对保证交付的渴望强烈建议您将需要保证交付的消息从事件中心复制到 Service Bus Topic or Queue 或者可能是 Azure SQL 数据库 table待处理。