From c8a51651baf366893b36e8bbfce0fcc2291240e5 Mon Sep 17 00:00:00 2001 From: Alexey Rodionov Date: Wed, 13 Sep 2023 13:22:02 -0700 Subject: [PATCH] Legacy checkpoint support (#38546) --- .../src/Listeners/EventHubMetricsProvider.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubMetricsProvider.cs b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubMetricsProvider.cs index 2aab89045bdb8..52bb424b36fc6 100644 --- a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubMetricsProvider.cs +++ b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Listeners/EventHubMetricsProvider.cs @@ -109,7 +109,8 @@ private EventHubsTriggerMetrics CreateTriggerMetrics(List p // In that case, LastEnqueuedSequenceNumber will be >= 0 if ((partitionProperties.LastEnqueuedSequenceNumber != -1 && partitionProperties.LastEnqueuedSequenceNumber != (checkpoint?.SequenceNumber ?? -1)) - || (checkpoint == null && partitionProperties.LastEnqueuedSequenceNumber >= 0)) + || (checkpoint == null && partitionProperties.LastEnqueuedSequenceNumber >= 0) + || (checkpoint != null && checkpoint.Offset == null && partitionProperties.LastEnqueuedSequenceNumber >= 0)) { long partitionUnprocessedEventCount = GetUnprocessedEventCount(partitionProperties, checkpoint); totalUnprocessedEventCount += partitionUnprocessedEventCount; @@ -157,6 +158,12 @@ private static long GetUnprocessedEventCount(PartitionProperties partitionInfo, return 1; } + // Legacy checkpoint support + if (checkpoint != null && checkpoint.Offset == null && partitionInfo.LastEnqueuedSequenceNumber >= 0) + { + return partitionInfo.LastEnqueuedSequenceNumber + 1; + } + var startingSequenceNumber = checkpoint?.SequenceNumber switch { // There was no checkpoint, use the beginning sequence number - 1, since