Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add objectid to idempotencekey snapshot oslo #339

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ await snapshotManager.FindMatchingSnapshot(

When<Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Envelope<StreetNameWasRemovedV2>>(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);
});
}

Expand All @@ -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<MessageHeader> { new MessageHeader(MessageHeader.IdempotenceKey, storePosition.ToString()) },
new List<MessageHeader> { 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);
}
}
}
Expand Down
Loading