From f8bc7c63b5227aef00da561595895a4b4a3e984c Mon Sep 17 00:00:00 2001 From: Arne Dumarey Date: Wed, 23 Oct 2024 09:05:26 +0200 Subject: [PATCH] fix(producer): add logging + catch gone when reproducing --- .../SnapshotReproducer.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/BuildingRegistry.Producer.Snapshot.Oslo/SnapshotReproducer.cs b/src/BuildingRegistry.Producer.Snapshot.Oslo/SnapshotReproducer.cs index 7db2aee4d..497be68df 100644 --- a/src/BuildingRegistry.Producer.Snapshot.Oslo/SnapshotReproducer.cs +++ b/src/BuildingRegistry.Producer.Snapshot.Oslo/SnapshotReproducer.cs @@ -2,6 +2,8 @@ { using System; using System.Collections.Generic; + using System.Net; + using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Be.Vlaanderen.Basisregisters.GrAr.Notifications; @@ -55,10 +57,22 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) //reproduce foreach (var id in idsToProcess) { - await FindAndProduce(async () => - await _osloProxy.GetSnapshot(id.PersistentLocalId.ToString(), stoppingToken), - id.Position, - stoppingToken); + try + { + await FindAndProduce(async () => + await _osloProxy.GetSnapshot(id.PersistentLocalId.ToString(), stoppingToken), + id.Position, + stoppingToken); + } + catch (HttpRequestException e) when (e.StatusCode == HttpStatusCode.Gone) + { + _logger.LogInformation($"Snapshot '{id}' gone"); + } + catch (Exception ex) + { + _logger.LogError($"Error while reproducing snapshot {id}", ex); + throw; + } } await Task.Delay(TimeSpan.FromHours(1), stoppingToken);