From 3026bba034f9603e032f092105dfb5737b829ad1 Mon Sep 17 00:00:00 2001 From: emalfroy Date: Fri, 26 Jan 2024 09:30:07 +0100 Subject: [PATCH] fix: add objectid to idempotencekey snapshot oslo --- .../ProducerProjections.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/StreetNameRegistry.Producer.Snapshot.Oslo/ProducerProjections.cs b/src/StreetNameRegistry.Producer.Snapshot.Oslo/ProducerProjections.cs index 55532f973..1a721d9ee 100644 --- a/src/StreetNameRegistry.Producer.Snapshot.Oslo/ProducerProjections.cs +++ b/src/StreetNameRegistry.Producer.Snapshot.Oslo/ProducerProjections.cs @@ -206,7 +206,7 @@ await snapshotManager.FindMatchingSnapshot( When>(async (_, message, ct) => { - await Produce($"{osloNamespace}/{message.Message.PersistentLocalId}", "{}", message.Position, ct); + await Produce($"{osloNamespace}/{message.Message.PersistentLocalId}", message.Message.PersistentLocalId.ToString(),"{}", message.Position, ct); }); } @@ -219,25 +219,26 @@ private async Task FindAndProduce( if (result != null) { - await Produce(result.Identificator.Id, result.JsonContent, storePosition, ct); + await Produce(result.Identificator.Id, result.Identificator.ObjectId, result.JsonContent, storePosition, ct); } } private async Task Produce( + string puri, string objectId, string jsonContent, long storePosition, CancellationToken cancellationToken = default) { var result = await _producer.Produce( - new MessageKey(objectId), + new MessageKey(puri), jsonContent, - new List { new MessageHeader(MessageHeader.IdempotenceKey, storePosition.ToString()) }, + new List { new MessageHeader(MessageHeader.IdempotenceKey, $"{objectId}-{storePosition.ToString()}") }, cancellationToken); if (!result.IsSuccess) { - throw new InvalidOperationException(result.Error + Environment.NewLine + result.ErrorReason); //TODO: create custom exception + throw new InvalidOperationException(result.Error + Environment.NewLine + result.ErrorReason); } } }